Bug 1358946 - Strip about:reader in intent data uri. r=maliu

MozReview-Commit-ID: AQ8txBAbtUr

--HG--
extra : amend_source : 5128c93b4796f3d9c568bf55aaa743c4493a0a84
This commit is contained in:
Nevin Chen 2017-05-18 19:39:00 -04:00
parent 4924c09590
commit f4108311cc
2 changed files with 16 additions and 7 deletions

View File

@ -4504,9 +4504,6 @@ Tab.prototype = {
ExternalApps.updatePageActionUri(fixedURI);
}
// Strip reader mode URI and also make it exposable if needed
fixedURI = this._stripAboutReaderURL(fixedURI);
let message = {
type: "Content:LocationChange",
tabID: this.id,
@ -4533,10 +4530,6 @@ Tab.prototype = {
}
},
_stripAboutReaderURL: function (originalURI) {
return ReaderMode.getOriginalUrlObjectForDisplay(originalURI.spec) || originalURI;
},
// Properties used to cache security state used to update the UI
_state: null,
_hostChanged: false, // onLocationChange will flip this bit

View File

@ -25,6 +25,7 @@ public class SafeIntent {
private final Intent intent;
public SafeIntent(final Intent intent) {
stripDataUri(intent);
this.intent = intent;
}
@ -131,4 +132,19 @@ public class SafeIntent {
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) {
intent.setData(Uri.parse(strippedUrl));
}
}
}
}
}