jenkins-bot has submitted this change and it was merged.

Change subject: Run disambiguation links through URLDecoder
......................................................................


Run disambiguation links through URLDecoder

This patch changes the app to run disambiguation links through a URL decoder,
and falls back to using the old system of displaying the encoded URL if
there's some problem with the decoding.

In some cases URL encoded links were shown to the user, which in the best
case just looks bad and is confusing, but in the worst case actually causes
the links to be incorrect and navigation to fail. This patch fixes that.

Bug: T97200
Change-Id: I4ed27184ad5ebb5bfe8ddfbea4b2fbc706c25918
---
M wikipedia/src/main/java/org/wikipedia/page/PageInfoHandler.java
1 file changed, 9 insertions(+), 2 deletions(-)

Approvals:
  Dbrant: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/wikipedia/src/main/java/org/wikipedia/page/PageInfoHandler.java 
b/wikipedia/src/main/java/org/wikipedia/page/PageInfoHandler.java
index 2771df7..bf4ada0 100644
--- a/wikipedia/src/main/java/org/wikipedia/page/PageInfoHandler.java
+++ b/wikipedia/src/main/java/org/wikipedia/page/PageInfoHandler.java
@@ -6,6 +6,8 @@
 import org.json.JSONArray;
 import org.json.JSONException;
 import org.json.JSONObject;
+import java.net.URLDecoder;
+import java.io.UnsupportedEncodingException;
 
 /**
  * A handler for both disambiguation and page issues information.
@@ -45,8 +47,13 @@
         }
         DisambigResult[] stringArray = new DisambigResult[array.length()];
         for (int i = 0; i < array.length(); i++) {
-            // Decode the href that we got into a PageTitle, and create a 
DisambigResult with it
-            stringArray[i] = new 
DisambigResult(getSite().titleForInternalLink(array.getString(i)));
+            try {
+                // Decode the href that we got into a PageTitle, and create a 
DisambigResult with it
+                stringArray[i] = new 
DisambigResult(getSite().titleForInternalLink(URLDecoder.decode(array.getString(i),
 "UTF-8")));
+            } catch (UnsupportedEncodingException e) {
+                // Inexplicable decoding problem. Display raw string to user. 
Better than nothing.
+                stringArray[i] = new 
DisambigResult(getSite().titleForInternalLink(array.getString(i)));
+            }
         }
         return stringArray;
     }

-- 
To view, visit https://gerrit.wikimedia.org/r/206625
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I4ed27184ad5ebb5bfe8ddfbea4b2fbc706c25918
Gerrit-PatchSet: 1
Gerrit-Project: apps/android/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Deskana <dga...@wikimedia.org>
Gerrit-Reviewer: BearND <bsitzm...@wikimedia.org>
Gerrit-Reviewer: Brion VIBBER <br...@wikimedia.org>
Gerrit-Reviewer: Dbrant <dbr...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to