Florianschmidtwelzow has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/354484 )
Change subject: Do not assume that all lead image thumb urls are without scheme ...................................................................... Do not assume that all lead image thumb urls are without scheme Until now, the app expects to get a thumb image URL returned from the api, which does not contain a scheme. This isn't true, at least not for all third-parties, where probably a https URL is returned through the API. The app now handles these URLs by parsing the returned URL to an URI object and sets the scheme from the WikiSite only, if there's no scheme in the URL already. Until now, the current implemtened handling would result in stupid things like: httpshttps://uploads.wikipedia.org... Bug: T165495 Change-Id: I96d624a3bdfe0c76890a1993dc31eb3af600a1bc --- M app/src/main/java/org/wikipedia/page/leadimages/LeadImagesHandler.java 1 file changed, 12 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/apps/android/wikipedia refs/changes/84/354484/1 diff --git a/app/src/main/java/org/wikipedia/page/leadimages/LeadImagesHandler.java b/app/src/main/java/org/wikipedia/page/leadimages/LeadImagesHandler.java index d935c98..ab13676 100755 --- a/app/src/main/java/org/wikipedia/page/leadimages/LeadImagesHandler.java +++ b/app/src/main/java/org/wikipedia/page/leadimages/LeadImagesHandler.java @@ -3,6 +3,7 @@ import android.content.DialogInterface; import android.graphics.Bitmap; import android.graphics.PointF; +import android.net.Uri; import android.support.annotation.ColorInt; import android.support.annotation.NonNull; import android.support.annotation.Nullable; @@ -206,12 +207,20 @@ } /** - * @param url Nullable URL with no scheme. For example, foo.bar.com/ instead of - * http://foo.bar.com/. + * @param url Nullable URL with or without scheme. */ private void loadLeadImage(@Nullable String url) { if (!isMainPage() && !TextUtils.isEmpty(url) && isLeadImageEnabled()) { - String fullUrl = getTitle().getWikiSite().scheme() + ":" + url; + Uri fullUri = Uri.parse(url); + String scheme = getTitle().getWikiSite().scheme(); + if (fullUri.getScheme() != null) { + scheme = fullUri.getScheme(); + } + String fullUrl = new Uri.Builder() + .scheme(scheme) + .authority(fullUri.getAuthority()) + .path(fullUri.getPath()) + .toString(); pageHeaderView.loadImage(fullUrl); } else { pageHeaderView.loadImage(null); -- To view, visit https://gerrit.wikimedia.org/r/354484 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I96d624a3bdfe0c76890a1993dc31eb3af600a1bc Gerrit-PatchSet: 1 Gerrit-Project: apps/android/wikipedia Gerrit-Branch: master Gerrit-Owner: Florianschmidtwelzow <florian.schmidt.stargatewis...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits