Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3957)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/util/IntentUtils.java

Issue 2392763002: Sanitize unparcable intents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix lint and findbugs Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/util/IntentUtils.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/util/IntentUtils.java b/chrome/android/java/src/org/chromium/chrome/browser/util/IntentUtils.java
index 3dffaf2bafcda5e7c5ba61545861da6c89435420..451bb1df8e38449ee0b9c3deeaece6243ed1a397 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/util/IntentUtils.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/util/IntentUtils.java
@@ -7,6 +7,7 @@ package org.chromium.chrome.browser.util;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
+import android.os.BadParcelableException;
import android.os.Binder;
import android.os.Bundle;
import android.os.IBinder;
@@ -365,4 +366,20 @@ public class IntentUtils {
throw e;
}
}
+
+ /**
+ * Sanitizes an intent. In case the intent cannot be unparcelled, all extras will be removed to
+ * make it safe to use.
+ * @return A safe to use version of this intent.
+ */
+ public static Intent sanitizeIntent(final Intent incomingIntent) {
+ if (incomingIntent == null) return null;
+ try {
+ incomingIntent.getBooleanExtra("TriggerUnparcel", false);
+ return incomingIntent;
+ } catch (BadParcelableException e) {
+ Log.e(TAG, "Invalid incoming intent.", e);
+ return incomingIntent.replaceExtras((Bundle) null);
+ }
+ }
}

Powered by Google App Engine
This is Rietveld 408576698