Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: mobile/android/geckoview/src/main/java/org/mozilla/gecko/mozglue/SafeIntent.java

Issue 29606596: Issue 6032 - Page not added to the Reading List (Closed)
Patch Set: Created Nov. 13, 2017, 10:23 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mobile/android/chrome/content/browser.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mobile/android/geckoview/src/main/java/org/mozilla/gecko/mozglue/SafeIntent.java
===================================================================
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/mozglue/SafeIntent.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/mozglue/SafeIntent.java
@@ -20,16 +20,17 @@ import java.util.ArrayList;
* for more.
*/
public class SafeIntent {
private static final String LOGTAG = "Gecko" + SafeIntent.class.getSimpleName();
private final Intent intent;
public SafeIntent(final Intent intent) {
+ stripDataUri(intent);
this.intent = intent;
}
public boolean hasExtra(String name) {
try {
return intent.hasExtra(name);
} catch (OutOfMemoryError e) {
Log.w(LOGTAG, "Couldn't determine if intent had an extra: OOM. Malformed?");
@@ -126,9 +127,24 @@ public class SafeIntent {
Log.w(LOGTAG, "Couldn't get intent data.", e);
return null;
}
}
public Intent getUnsafe() {
return intent;
}
+
+ private static void stripDataUri(final Intent intent) {
+ // We should limit intent filters and check incoming intents against white-list
+ // But for now we just strip 'about:reader?url='
+ if (intent != null && intent.getData() != null) {
+ final String url = intent.getData().toString();
+ final String prefix = "about:reader?url=";
+ if (url != null && url.startsWith(prefix)) {
+ final String strippedUrl = url.replace(prefix, "");
+ if (strippedUrl != null) {
jens 2017/11/14 11:17:51 Maybe we should also check && !strippedUrl.isEmpty
diegocarloslima 2017/11/14 11:22:10 Actually I'm just using the solution that Mozilla
+ intent.setData(Uri.parse(strippedUrl));
+ }
+ }
+ }
+ }
}
« no previous file with comments | « mobile/android/chrome/content/browser.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld