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

Commit 96f4ca0f authored by Chiachang Wang's avatar Chiachang Wang Committed by Automerger Merge Worker
Browse files

Merge "Stop using invalid URL to prevent unexpected crash" into qt-dev am:...

Merge "Stop using invalid URL to prevent unexpected crash" into qt-dev am: 3ac8d1dc am: dadbab8a am: 14f1bec4

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18715266



Change-Id: I9910ae29bb623c60b2b8d3794a2f25f673ac4904
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents ba83a114 14f1bec4
Loading
Loading
Loading
Loading
+17 −2
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import android.os.SystemClock;
import android.os.SystemProperties;
import android.provider.Settings;
import android.util.Log;
import android.webkit.URLUtil;

import com.android.internal.annotations.GuardedBy;
import com.android.internal.util.TrafficStatsConstants;
@@ -215,8 +216,22 @@ public class PacManager {
     * @throws IOException if the URL is malformed, or the PAC file is too big.
     */
    private static String get(Uri pacUri) throws IOException {
        URL url = new URL(pacUri.toString());
        URLConnection urlConnection = url.openConnection(java.net.Proxy.NO_PROXY);
        if (!URLUtil.isValidUrl(pacUri.toString()))  {
            throw new IOException("Malformed URL:" + pacUri);
        }

        final URL url = new URL(pacUri.toString());
        URLConnection urlConnection;
        try {
            urlConnection = url.openConnection(java.net.Proxy.NO_PROXY);
            // Catch the possible exceptions and rethrow as IOException to not to crash the system
            // for illegal input.
        } catch (IllegalArgumentException e) {
            throw new IOException("Incorrect proxy type for " + pacUri);
        } catch (UnsupportedOperationException e) {
            throw new IOException("Unsupported URL connection type for " + pacUri);
        }

        long contentLength = -1;
        try {
            contentLength = Long.parseLong(urlConnection.getHeaderField("Content-Length"));