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

Commit 559e91e0 authored by Fedor Kudasov's avatar Fedor Kudasov Committed by Chalard Jean
Browse files

Revert "Cherry-pick the relevant parts of master change"

This reverts commit dd16d44f.

Reason for revert: multiple build breakages b/137069068

Change-Id: If48bfa2d2cab0877a053743b3ec53820d0c4ed6b
parent e5cb0a22
Loading
Loading
Loading
Loading
+0 −31
Original line number Original line Diff line number Diff line
@@ -16,15 +16,10 @@


package android.net;
package android.net;


import static android.system.OsConstants.AF_INET;
import static android.system.OsConstants.AF_INET6;

import android.annotation.NonNull;
import android.annotation.UnsupportedAppUsage;
import android.annotation.UnsupportedAppUsage;
import android.net.shared.Inet4AddressUtils;
import android.net.shared.Inet4AddressUtils;
import android.os.Build;
import android.os.Build;
import android.system.ErrnoException;
import android.system.ErrnoException;
import android.system.Os;
import android.util.Log;
import android.util.Log;
import android.util.Pair;
import android.util.Pair;


@@ -459,30 +454,4 @@ public class NetworkUtils {
        }
        }
        return routedIPCount;
        return routedIPCount;
    }
    }

    private static final int[] ADDRESS_FAMILIES = new int[] {AF_INET, AF_INET6};

    /**
     * Returns true if the hostname is weakly validated.
     * @param hostname Name of host to validate.
     * @return True if it's a valid-ish hostname.
     *
     * @hide
     */
    public static boolean isWeaklyValidatedHostname(@NonNull String hostname) {
        // TODO(b/34953048): Use a validation method that permits more accurate,
        // but still inexpensive, checking of likely valid DNS hostnames.
        final String weakHostnameRegex = "^[a-zA-Z0-9_.-]+$";
        if (!hostname.matches(weakHostnameRegex)) {
            return false;
        }

        for (int address_family : ADDRESS_FAMILIES) {
            if (Os.inet_pton(address_family, hostname) != null) {
                return false;
            }
        }

        return true;
    }
}
}