| 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)); |
| + } |
| + } |
| + } |
| + } |
| } |