Remove path, query, and fragment from http Uri.
For http and https schemes leave only scheme and authority in
Uri.toSafeString().
Fixes bug 19217173.
Change-Id: Ic07665f4754bb33ad48f7a55ce5efda185df7577
diff --git a/core/java/android/net/Uri.java b/core/java/android/net/Uri.java
index 2099c3f..bf3d9aa 100644
--- a/core/java/android/net/Uri.java
+++ b/core/java/android/net/Uri.java
@@ -366,6 +366,7 @@
public String toSafeString() {
String scheme = getScheme();
String ssp = getSchemeSpecificPart();
+ String authority = null;
if (scheme != null) {
if (scheme.equalsIgnoreCase("tel") || scheme.equalsIgnoreCase("sip")
|| scheme.equalsIgnoreCase("sms") || scheme.equalsIgnoreCase("smsto")
@@ -384,6 +385,9 @@
}
}
return builder.toString();
+ } else if (scheme.equalsIgnoreCase("http") || scheme.equalsIgnoreCase("https")) {
+ ssp = null;
+ authority = "//" + getAuthority() + "/...";
}
}
// Not a sensitive scheme, but let's still be conservative about
@@ -397,6 +401,9 @@
if (ssp != null) {
builder.append(ssp);
}
+ if (authority != null) {
+ builder.append(authority);
+ }
return builder.toString();
}
@@ -1742,7 +1749,7 @@
*
* @return normalized Uri (never null)
* @see {@link android.content.Intent#setData}
- * @see {@link #setNormalizedData}
+ * @see {@link android.content.Intent#setDataAndNormalize}
*/
public Uri normalizeScheme() {
String scheme = getScheme();