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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/UrlUtilitiesTest.java

Issue 1059413004: Add a validator for intent:// URLs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Why are the presubmit checks different on the bots vs. local? import org.chromium.base.Log; Created 5 years, 8 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
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/UrlUtilities.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/javatests/src/org/chromium/chrome/browser/UrlUtilitiesTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/UrlUtilitiesTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/UrlUtilitiesTest.java
index d40403d745a2a240504169124b6b29b104666730..803254473a045df483f39a0d1e3e7d6e94425931 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/UrlUtilitiesTest.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/UrlUtilitiesTest.java
@@ -104,4 +104,59 @@ public class UrlUtilitiesTest extends InstrumentationTestCase {
assertEquals("about:blank", UrlUtilities.getOriginForDisplay(uri, false));
}
+ @SmallTest
+ public void testValidateIntentUrl() {
+ // Valid action, hostname, and (empty) path.
+ assertTrue(UrlUtilities.validateIntentUrl(
+ "intent://10010#Intent;scheme=tel;action=com.google.android.apps."
+ + "authenticator.AUTHENTICATE;end"));
+ // Valid package, scheme, hostname, and path.
+ assertTrue(UrlUtilities.validateIntentUrl(
+ "intent://scan/#Intent;package=com.google.zxing.client.android;"
+ + "scheme=zxing;end;"));
+ // Valid package, scheme, component, hostname, and path.
+ assertTrue(UrlUtilities.validateIntentUrl(
+ "intent://wump-hey.example.com/#Intent;package=com.example.wump;"
+ + "scheme=yow;component=com.example.PUMPKIN;end;"));
+ // Valid package, scheme, action, hostname, and path.
+ assertTrue(UrlUtilities.validateIntentUrl(
+ "intent://wump-hey.example.com/#Intent;package=com.example.wump;"
+ + "scheme=eeek;action=frighten_children;end;"));
+ // Valid package, component, String extra, hostname, and path.
+ assertTrue(UrlUtilities.validateIntentUrl(
+ "intent://testing/#Intent;package=cybergoat.noodle.crumpet;"
+ + "component=wump.noodle/Crumpet;S.goat=leg;end"));
+
+ // Valid package, component, int extra (with URL-encoded key), String
+ // extra, hostname, and path.
+ assertTrue(UrlUtilities.validateIntentUrl(
+ "intent://testing/#Intent;package=cybergoat.noodle.crumpet;"
+ + "component=wump.noodle/Crumpet;i.pumpkinCount%3D=42;"
+ + "S.goat=leg;end"));
+
+ // Junk after end.
+ assertFalse(UrlUtilities.validateIntentUrl(
+ "intent://10010#Intent;scheme=tel;action=com.google.android.apps."
+ + "authenticator.AUTHENTICATE;end','*');"
+ + "alert(document.cookie);//"));
+ // component appears twice.
+ assertFalse(UrlUtilities.validateIntentUrl(
+ "intent://wump-hey.example.com/#Intent;package=com.example.wump;"
+ + "scheme=yow;component=com.example.PUMPKIN;"
+ + "component=com.example.AVOCADO;end;"));
+ // scheme contains illegal character.
+ assertFalse(UrlUtilities.validateIntentUrl(
+ "intent://wump-hey.example.com/#Intent;package=com.example.wump;"
+ + "scheme=hello+goodbye;component=com.example.PUMPKIN;end;"));
+ // category contains illegal character.
+ assertFalse(UrlUtilities.validateIntentUrl(
+ "intent://wump-hey.example.com/#Intent;package=com.example.wump;"
+ + "category=42%_by_volume;end"));
+ // Incorrectly URL-encoded.
+ assertFalse(UrlUtilities.validateIntentUrl(
+ "intent://testing/#Intent;package=cybergoat.noodle.crumpet;"
+ + "component=wump.noodle/Crumpet;i.pumpkinCount%%3D=42;"
+ + "S.goat=⋚end"));
+ }
+
}
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/UrlUtilities.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698