Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b2a958fd authored by Craig Mautner's avatar Craig Mautner
Browse files

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
parent ea54c0f9
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -366,6 +366,7 @@ public abstract class Uri implements Parcelable, Comparable<Uri> {
    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 @@ public abstract class Uri implements Parcelable, Comparable<Uri> {
                    }
                }
                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 @@ public abstract class Uri implements Parcelable, Comparable<Uri> {
        if (ssp != null) {
            builder.append(ssp);
        }
        if (authority != null) {
            builder.append(authority);
        }
        return builder.toString();
    }

@@ -1742,7 +1749,7 @@ public abstract class Uri implements Parcelable, Comparable<Uri> {
     *
     * @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();