1359 lines
50 KiB
Java
1359 lines
50 KiB
Java
|
package com.airbnb.deeplinkdispatch;
|
||
|
|
||
|
import com.google.common.primitives.UnsignedBytes;
|
||
|
import io.grpc.internal.GrpcUtil;
|
||
|
import java.io.EOFException;
|
||
|
import java.net.IDN;
|
||
|
import java.net.InetAddress;
|
||
|
import java.net.MalformedURLException;
|
||
|
import java.net.URI;
|
||
|
import java.net.URISyntaxException;
|
||
|
import java.net.URL;
|
||
|
import java.net.UnknownHostException;
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.Collections;
|
||
|
import java.util.HashMap;
|
||
|
import java.util.HashSet;
|
||
|
import java.util.Iterator;
|
||
|
import java.util.LinkedHashSet;
|
||
|
import java.util.List;
|
||
|
import java.util.Locale;
|
||
|
import java.util.Map;
|
||
|
import java.util.Set;
|
||
|
import java.util.regex.Matcher;
|
||
|
import java.util.regex.Pattern;
|
||
|
import o.C14957gcv;
|
||
|
import o.C15111ghZ;
|
||
|
import o.gdP;
|
||
|
|
||
|
/* loaded from: classes.dex */
|
||
|
public final class DeepLinkUri {
|
||
|
static final String CONVERT_TO_URI_ENCODE_SET = "^`{}|\\";
|
||
|
static final String FORM_ENCODE_SET = " \"':;<=>@[]^`{}|/\\?#&!$(),~";
|
||
|
static final String FRAGMENT_ENCODE_SET = "";
|
||
|
static final String PASSWORD_ENCODE_SET = " \"':;<=>@[]^`{}|/\\?#";
|
||
|
static final String PATH_SEGMENT_ENCODE_SET = " \"<>^`{}|/\\?#";
|
||
|
static final String QUERY_COMPONENT_ENCODE_SET = " \"'<>#&=";
|
||
|
static final String QUERY_ENCODE_SET = " \"'<>#";
|
||
|
static final String USERNAME_ENCODE_SET = " \"':;<=>@[]^`{}|/\\?#";
|
||
|
private final String fragment;
|
||
|
private final String host;
|
||
|
private final String password;
|
||
|
private final List<String> pathSegments;
|
||
|
private final int port;
|
||
|
private final List<String> queryNamesAndValues;
|
||
|
private final String scheme;
|
||
|
private final String url;
|
||
|
private String urlTemplate;
|
||
|
private final String username;
|
||
|
private static final char[] HEX_DIGITS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
|
||
|
static final Pattern PLACEHOLDER_REGEX = Pattern.compile("\\{(.*?)\\}");
|
||
|
|
||
|
static int decodeHexDigit(char c) {
|
||
|
if (c >= '0' && c <= '9') {
|
||
|
return c - '0';
|
||
|
}
|
||
|
if (c >= 'a' && c <= 'f') {
|
||
|
return c - 'W';
|
||
|
}
|
||
|
if (c < 'A' || c > 'F') {
|
||
|
return -1;
|
||
|
}
|
||
|
return c - '7';
|
||
|
}
|
||
|
|
||
|
private DeepLinkUri(Builder builder, String str) {
|
||
|
this.scheme = builder.scheme;
|
||
|
this.username = percentDecode(builder.encodedUsername);
|
||
|
this.password = percentDecode(builder.encodedPassword);
|
||
|
this.host = builder.host;
|
||
|
this.port = builder.effectivePort();
|
||
|
this.pathSegments = percentDecode(builder.encodedPathSegments);
|
||
|
this.queryNamesAndValues = builder.encodedQueryNamesAndValues != null ? percentDecode(builder.encodedQueryNamesAndValues) : null;
|
||
|
this.fragment = builder.encodedFragment != null ? percentDecode(builder.encodedFragment) : null;
|
||
|
this.url = builder.toString();
|
||
|
this.urlTemplate = str;
|
||
|
}
|
||
|
|
||
|
final URL url() {
|
||
|
try {
|
||
|
return new URL(this.url);
|
||
|
} catch (MalformedURLException e) {
|
||
|
throw new RuntimeException(e);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
final URI uri() {
|
||
|
try {
|
||
|
return new URI(canonicalize(this.url, CONVERT_TO_URI_ENCODE_SET, true, false));
|
||
|
} catch (URISyntaxException unused) {
|
||
|
throw new IllegalStateException("not valid as a java.net.URI: ".concat(String.valueOf(this.url)));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
final boolean isHttps() {
|
||
|
return this.scheme.equals("https");
|
||
|
}
|
||
|
|
||
|
final String encodedUsername() {
|
||
|
if (this.username.isEmpty()) {
|
||
|
return "";
|
||
|
}
|
||
|
int length = this.scheme.length() + 3;
|
||
|
String str = this.url;
|
||
|
return this.url.substring(length, delimiterOffset(str, length, str.length(), ":@"));
|
||
|
}
|
||
|
|
||
|
final String encodedPassword() {
|
||
|
if (this.password.isEmpty()) {
|
||
|
return "";
|
||
|
}
|
||
|
int indexOf = this.url.indexOf(58, this.scheme.length() + 3);
|
||
|
return this.url.substring(indexOf + 1, this.url.indexOf(64));
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public final String encodedHost() {
|
||
|
return canonicalize(this.host, CONVERT_TO_URI_ENCODE_SET, true, true);
|
||
|
}
|
||
|
|
||
|
static int defaultPort(String str) {
|
||
|
if (str.equals("http")) {
|
||
|
return 80;
|
||
|
}
|
||
|
if (str.equals("https")) {
|
||
|
return GrpcUtil.DEFAULT_PORT_SSL;
|
||
|
}
|
||
|
return -1;
|
||
|
}
|
||
|
|
||
|
final int pathSize() {
|
||
|
return this.pathSegments.size();
|
||
|
}
|
||
|
|
||
|
final String encodedPath() {
|
||
|
int indexOf = this.url.indexOf(47, this.scheme.length() + 3);
|
||
|
String str = this.url;
|
||
|
return this.url.substring(indexOf, delimiterOffset(str, indexOf, str.length(), "?#"));
|
||
|
}
|
||
|
|
||
|
static void pathSegmentsToString(StringBuilder sb, List<String> list) {
|
||
|
int size = list.size();
|
||
|
for (int i = 0; i < size; i++) {
|
||
|
sb.append('/');
|
||
|
sb.append(list.get(i));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public final List<String> encodedPathSegments() {
|
||
|
int indexOf = this.url.indexOf(47, this.scheme.length() + 3);
|
||
|
String str = this.url;
|
||
|
int delimiterOffset = delimiterOffset(str, indexOf, str.length(), "?#");
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
while (indexOf < delimiterOffset) {
|
||
|
int i = indexOf + 1;
|
||
|
int delimiterOffset2 = delimiterOffset(this.url, i, delimiterOffset, "/");
|
||
|
arrayList.add(this.url.substring(i, delimiterOffset2));
|
||
|
indexOf = delimiterOffset2;
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
final String encodedQuery() {
|
||
|
if (this.queryNamesAndValues == null) {
|
||
|
return null;
|
||
|
}
|
||
|
int indexOf = this.url.indexOf(63);
|
||
|
String str = this.url;
|
||
|
return this.url.substring(indexOf + 1, delimiterOffset(str, indexOf + 2, str.length(), "#"));
|
||
|
}
|
||
|
|
||
|
static void namesAndValuesToQueryString(StringBuilder sb, List<String> list) {
|
||
|
int size = list.size();
|
||
|
for (int i = 0; i < size; i += 2) {
|
||
|
String str = list.get(i);
|
||
|
String str2 = list.get(i + 1);
|
||
|
if (i > 0) {
|
||
|
sb.append('&');
|
||
|
}
|
||
|
sb.append(str);
|
||
|
if (str2 != null) {
|
||
|
sb.append('=');
|
||
|
sb.append(str2);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
static List<String> queryStringToNamesAndValues(String str) {
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
int i = 0;
|
||
|
while (i <= str.length()) {
|
||
|
int indexOf = str.indexOf(38, i);
|
||
|
if (indexOf == -1) {
|
||
|
indexOf = str.length();
|
||
|
}
|
||
|
int indexOf2 = str.indexOf(61, i);
|
||
|
if (indexOf2 == -1 || indexOf2 > indexOf) {
|
||
|
arrayList.add(str.substring(i, indexOf));
|
||
|
arrayList.add(null);
|
||
|
} else {
|
||
|
arrayList.add(str.substring(i, indexOf2));
|
||
|
arrayList.add(str.substring(indexOf2 + 1, indexOf));
|
||
|
}
|
||
|
i = indexOf + 1;
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
final String query() {
|
||
|
if (this.queryNamesAndValues == null) {
|
||
|
return null;
|
||
|
}
|
||
|
StringBuilder sb = new StringBuilder();
|
||
|
namesAndValuesToQueryString(sb, this.queryNamesAndValues);
|
||
|
return sb.toString();
|
||
|
}
|
||
|
|
||
|
public final Set<String> getSchemeHostPathPlaceholders() {
|
||
|
if (toTemplateString() == null) {
|
||
|
return Collections.emptySet();
|
||
|
}
|
||
|
if (query() == null || query().isEmpty()) {
|
||
|
return getPlaceHolders(toTemplateString());
|
||
|
}
|
||
|
return getPlaceHolders(toTemplateString().substring(0, toTemplateString().indexOf(query())));
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: private */
|
||
|
public static Set<String> getPlaceHolders(String str) {
|
||
|
Matcher matcher = PLACEHOLDER_REGEX.matcher(str);
|
||
|
HashSet hashSet = new HashSet(matcher.groupCount());
|
||
|
while (matcher.find()) {
|
||
|
for (int i = 1; i <= matcher.groupCount(); i++) {
|
||
|
hashSet.add(matcher.group(i));
|
||
|
}
|
||
|
}
|
||
|
return hashSet;
|
||
|
}
|
||
|
|
||
|
final int querySize() {
|
||
|
List<String> list = this.queryNamesAndValues;
|
||
|
if (list != null) {
|
||
|
return list.size() / 2;
|
||
|
}
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
final String queryParameter(String str) {
|
||
|
List<String> list = this.queryNamesAndValues;
|
||
|
if (list == null) {
|
||
|
return null;
|
||
|
}
|
||
|
int size = list.size();
|
||
|
for (int i = 0; i < size; i += 2) {
|
||
|
if (str.equals(this.queryNamesAndValues.get(i))) {
|
||
|
return this.queryNamesAndValues.get(i + 1);
|
||
|
}
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
public final Set<String> queryParameterNames() {
|
||
|
if (this.queryNamesAndValues == null) {
|
||
|
return Collections.emptySet();
|
||
|
}
|
||
|
LinkedHashSet linkedHashSet = new LinkedHashSet();
|
||
|
int size = this.queryNamesAndValues.size();
|
||
|
for (int i = 0; i < size; i += 2) {
|
||
|
linkedHashSet.add(this.queryNamesAndValues.get(i));
|
||
|
}
|
||
|
return Collections.unmodifiableSet(linkedHashSet);
|
||
|
}
|
||
|
|
||
|
public final List<String> queryParameterValues(String str) {
|
||
|
if (this.queryNamesAndValues == null) {
|
||
|
return Collections.emptyList();
|
||
|
}
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
int size = this.queryNamesAndValues.size();
|
||
|
for (int i = 0; i < size; i += 2) {
|
||
|
if (str.equals(this.queryNamesAndValues.get(i))) {
|
||
|
arrayList.add(this.queryNamesAndValues.get(i + 1));
|
||
|
}
|
||
|
}
|
||
|
return Collections.unmodifiableList(arrayList);
|
||
|
}
|
||
|
|
||
|
final String queryParameterName(int i) {
|
||
|
return this.queryNamesAndValues.get(i << 1);
|
||
|
}
|
||
|
|
||
|
final String queryParameterValue(int i) {
|
||
|
return this.queryNamesAndValues.get((i << 1) + 1);
|
||
|
}
|
||
|
|
||
|
final String encodedFragment() {
|
||
|
if (this.fragment == null) {
|
||
|
return null;
|
||
|
}
|
||
|
return this.url.substring(this.url.indexOf(35) + 1);
|
||
|
}
|
||
|
|
||
|
final DeepLinkUri resolve(String str) {
|
||
|
Builder builder = new Builder();
|
||
|
if (builder.parse(this, str, false) == Builder.ParseResult.SUCCESS) {
|
||
|
return builder.build();
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
final Builder newBuilder() {
|
||
|
Builder builder = new Builder();
|
||
|
builder.scheme = this.scheme;
|
||
|
builder.encodedUsername = encodedUsername();
|
||
|
builder.encodedPassword = encodedPassword();
|
||
|
builder.host = this.host;
|
||
|
builder.port = this.port;
|
||
|
builder.encodedPathSegments.clear();
|
||
|
builder.encodedPathSegments.addAll(encodedPathSegments());
|
||
|
builder.encodedQuery(encodedQuery());
|
||
|
builder.encodedFragment = encodedFragment();
|
||
|
return builder;
|
||
|
}
|
||
|
|
||
|
public static DeepLinkUri parse(String str) {
|
||
|
return parse(str, false);
|
||
|
}
|
||
|
|
||
|
public static DeepLinkUri parseTemplate(String str) {
|
||
|
return parse(str, true);
|
||
|
}
|
||
|
|
||
|
private static DeepLinkUri parse(String str, boolean z) {
|
||
|
Builder builder = new Builder();
|
||
|
if (builder.parse(null, str, z) == Builder.ParseResult.SUCCESS) {
|
||
|
return builder.build();
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
static DeepLinkUri get(URL url) {
|
||
|
return parse(url.toString());
|
||
|
}
|
||
|
|
||
|
static DeepLinkUri getChecked(String str) throws MalformedURLException, UnknownHostException {
|
||
|
Builder builder = new Builder();
|
||
|
Builder.ParseResult parse = builder.parse(null, str, false);
|
||
|
int i = AnonymousClass1.$SwitchMap$com$airbnb$deeplinkdispatch$DeepLinkUri$Builder$ParseResult[parse.ordinal()];
|
||
|
if (i == 1) {
|
||
|
return builder.build();
|
||
|
}
|
||
|
if (i == 2) {
|
||
|
throw new UnknownHostException("Invalid host: ".concat(String.valueOf(str)));
|
||
|
}
|
||
|
StringBuilder sb = new StringBuilder("Invalid URL: ");
|
||
|
sb.append(parse);
|
||
|
sb.append(" for ");
|
||
|
sb.append(str);
|
||
|
throw new MalformedURLException(sb.toString());
|
||
|
}
|
||
|
|
||
|
/* renamed from: com.airbnb.deeplinkdispatch.DeepLinkUri$1, reason: invalid class name */
|
||
|
/* loaded from: classes.dex */
|
||
|
static /* synthetic */ class AnonymousClass1 {
|
||
|
static final int[] $SwitchMap$com$airbnb$deeplinkdispatch$DeepLinkUri$Builder$ParseResult;
|
||
|
|
||
|
static {
|
||
|
int[] iArr = new int[Builder.ParseResult.values().length];
|
||
|
$SwitchMap$com$airbnb$deeplinkdispatch$DeepLinkUri$Builder$ParseResult = iArr;
|
||
|
try {
|
||
|
iArr[Builder.ParseResult.SUCCESS.ordinal()] = 1;
|
||
|
} catch (NoSuchFieldError unused) {
|
||
|
}
|
||
|
try {
|
||
|
$SwitchMap$com$airbnb$deeplinkdispatch$DeepLinkUri$Builder$ParseResult[Builder.ParseResult.INVALID_HOST.ordinal()] = 2;
|
||
|
} catch (NoSuchFieldError unused2) {
|
||
|
}
|
||
|
try {
|
||
|
$SwitchMap$com$airbnb$deeplinkdispatch$DeepLinkUri$Builder$ParseResult[Builder.ParseResult.UNSUPPORTED_SCHEME.ordinal()] = 3;
|
||
|
} catch (NoSuchFieldError unused3) {
|
||
|
}
|
||
|
try {
|
||
|
$SwitchMap$com$airbnb$deeplinkdispatch$DeepLinkUri$Builder$ParseResult[Builder.ParseResult.MISSING_SCHEME.ordinal()] = 4;
|
||
|
} catch (NoSuchFieldError unused4) {
|
||
|
}
|
||
|
try {
|
||
|
$SwitchMap$com$airbnb$deeplinkdispatch$DeepLinkUri$Builder$ParseResult[Builder.ParseResult.INVALID_PORT.ordinal()] = 5;
|
||
|
} catch (NoSuchFieldError unused5) {
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
static DeepLinkUri get(URI uri) {
|
||
|
return parse(uri.toString());
|
||
|
}
|
||
|
|
||
|
public final boolean equals(Object obj) {
|
||
|
return (obj instanceof DeepLinkUri) && ((DeepLinkUri) obj).url.equals(this.url);
|
||
|
}
|
||
|
|
||
|
public final int hashCode() {
|
||
|
return this.url.hashCode();
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* loaded from: classes.dex */
|
||
|
public static final class Builder {
|
||
|
String encodedFragment;
|
||
|
final List<String> encodedPathSegments;
|
||
|
List<String> encodedQueryNamesAndValues;
|
||
|
String host;
|
||
|
String scheme;
|
||
|
String templateUrl;
|
||
|
String encodedUsername = "";
|
||
|
String encodedPassword = "";
|
||
|
int port = -1;
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* loaded from: classes.dex */
|
||
|
public enum ParseResult {
|
||
|
SUCCESS,
|
||
|
MISSING_SCHEME,
|
||
|
UNSUPPORTED_SCHEME,
|
||
|
INVALID_PORT,
|
||
|
INVALID_HOST
|
||
|
}
|
||
|
|
||
|
Builder() {
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
this.encodedPathSegments = arrayList;
|
||
|
arrayList.add("");
|
||
|
}
|
||
|
|
||
|
final Builder scheme(String str) {
|
||
|
if (str == null) {
|
||
|
throw new IllegalArgumentException("scheme == null");
|
||
|
}
|
||
|
this.scheme = str;
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
final Builder username(String str) {
|
||
|
if (str == null) {
|
||
|
throw new IllegalArgumentException("username == null");
|
||
|
}
|
||
|
this.encodedUsername = DeepLinkUri.canonicalize(str, " \"':;<=>@[]^`{}|/\\?#", false, false);
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
final Builder encodedUsername(String str) {
|
||
|
if (str == null) {
|
||
|
throw new IllegalArgumentException("encodedUsername == null");
|
||
|
}
|
||
|
this.encodedUsername = DeepLinkUri.canonicalize(str, " \"':;<=>@[]^`{}|/\\?#", true, false);
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
final Builder password(String str) {
|
||
|
if (str == null) {
|
||
|
throw new IllegalArgumentException("password == null");
|
||
|
}
|
||
|
this.encodedPassword = DeepLinkUri.canonicalize(str, " \"':;<=>@[]^`{}|/\\?#", false, false);
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
final Builder encodedPassword(String str) {
|
||
|
if (str == null) {
|
||
|
throw new IllegalArgumentException("encodedPassword == null");
|
||
|
}
|
||
|
this.encodedPassword = DeepLinkUri.canonicalize(str, " \"':;<=>@[]^`{}|/\\?#", true, false);
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
final Builder host(String str) {
|
||
|
if (str == null) {
|
||
|
throw new IllegalArgumentException("host == null");
|
||
|
}
|
||
|
String canonicalizeHost = canonicalizeHost(str, 0, str.length());
|
||
|
if (canonicalizeHost == null) {
|
||
|
throw new IllegalArgumentException("unexpected host: ".concat(String.valueOf(str)));
|
||
|
}
|
||
|
this.host = canonicalizeHost;
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
final Builder port(int i) {
|
||
|
if (i <= 0 || i > 65535) {
|
||
|
throw new IllegalArgumentException("unexpected port: ".concat(String.valueOf(i)));
|
||
|
}
|
||
|
this.port = i;
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
final int effectivePort() {
|
||
|
int i = this.port;
|
||
|
return i == -1 ? DeepLinkUri.defaultPort(this.scheme) : i;
|
||
|
}
|
||
|
|
||
|
final Builder addPathSegment(String str) {
|
||
|
if (str == null) {
|
||
|
throw new IllegalArgumentException("pathSegment == null");
|
||
|
}
|
||
|
push(str, 0, str.length(), false, false);
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
final Builder addEncodedPathSegment(String str) {
|
||
|
if (str == null) {
|
||
|
throw new IllegalArgumentException("encodedPathSegment == null");
|
||
|
}
|
||
|
push(str, 0, str.length(), false, true);
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
final Builder setPathSegment(int i, String str) {
|
||
|
if (str == null) {
|
||
|
throw new IllegalArgumentException("pathSegment == null");
|
||
|
}
|
||
|
String canonicalize = DeepLinkUri.canonicalize(str, 0, str.length(), " \"<>^`{}|/\\?#", false, false);
|
||
|
if (isDot(canonicalize) || isDotDot(canonicalize)) {
|
||
|
throw new IllegalArgumentException("unexpected path segment: ".concat(String.valueOf(str)));
|
||
|
}
|
||
|
this.encodedPathSegments.set(i, canonicalize);
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
final Builder setEncodedPathSegment(int i, String str) {
|
||
|
if (str == null) {
|
||
|
throw new IllegalArgumentException("encodedPathSegment == null");
|
||
|
}
|
||
|
String canonicalize = DeepLinkUri.canonicalize(str, 0, str.length(), " \"<>^`{}|/\\?#", true, false);
|
||
|
this.encodedPathSegments.set(i, canonicalize);
|
||
|
if (isDot(canonicalize) || isDotDot(canonicalize)) {
|
||
|
throw new IllegalArgumentException("unexpected path segment: ".concat(String.valueOf(str)));
|
||
|
}
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
final Builder removePathSegment(int i) {
|
||
|
this.encodedPathSegments.remove(i);
|
||
|
if (this.encodedPathSegments.isEmpty()) {
|
||
|
this.encodedPathSegments.add("");
|
||
|
}
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
final Builder encodedPath(String str) {
|
||
|
if (str == null) {
|
||
|
throw new IllegalArgumentException("encodedPath == null");
|
||
|
}
|
||
|
if (!str.startsWith("/")) {
|
||
|
throw new IllegalArgumentException("unexpected encodedPath: ".concat(String.valueOf(str)));
|
||
|
}
|
||
|
resolvePath(str, 0, str.length());
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
final Builder query(String str) {
|
||
|
this.encodedQueryNamesAndValues = str != null ? DeepLinkUri.queryStringToNamesAndValues(DeepLinkUri.canonicalize(str, " \"'<>#", false, true)) : null;
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
final Builder encodedQuery(String str) {
|
||
|
this.encodedQueryNamesAndValues = str != null ? DeepLinkUri.queryStringToNamesAndValues(DeepLinkUri.canonicalize(str, " \"'<>#", true, true)) : null;
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
final Builder addQueryParameter(String str, String str2) {
|
||
|
if (str == null) {
|
||
|
throw new IllegalArgumentException("name == null");
|
||
|
}
|
||
|
if (this.encodedQueryNamesAndValues == null) {
|
||
|
this.encodedQueryNamesAndValues = new ArrayList();
|
||
|
}
|
||
|
this.encodedQueryNamesAndValues.add(DeepLinkUri.canonicalize(str, " \"'<>#&=", false, true));
|
||
|
this.encodedQueryNamesAndValues.add(str2 != null ? DeepLinkUri.canonicalize(str2, " \"'<>#&=", false, true) : null);
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
final Builder addEncodedQueryParameter(String str, String str2) {
|
||
|
if (str == null) {
|
||
|
throw new IllegalArgumentException("encodedName == null");
|
||
|
}
|
||
|
if (this.encodedQueryNamesAndValues == null) {
|
||
|
this.encodedQueryNamesAndValues = new ArrayList();
|
||
|
}
|
||
|
this.encodedQueryNamesAndValues.add(DeepLinkUri.canonicalize(str, " \"'<>#&=", true, true));
|
||
|
this.encodedQueryNamesAndValues.add(str2 != null ? DeepLinkUri.canonicalize(str2, " \"'<>#&=", true, true) : null);
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
final Builder setQueryParameter(String str, String str2) {
|
||
|
removeAllQueryParameters(str);
|
||
|
addQueryParameter(str, str2);
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
final Builder setEncodedQueryParameter(String str, String str2) {
|
||
|
removeAllEncodedQueryParameters(str);
|
||
|
addEncodedQueryParameter(str, str2);
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
final Builder removeAllQueryParameters(String str) {
|
||
|
if (str == null) {
|
||
|
throw new IllegalArgumentException("name == null");
|
||
|
}
|
||
|
if (this.encodedQueryNamesAndValues == null) {
|
||
|
return this;
|
||
|
}
|
||
|
removeAllCanonicalQueryParameters(DeepLinkUri.canonicalize(str, " \"'<>#&=", false, true));
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
final Builder removeAllEncodedQueryParameters(String str) {
|
||
|
if (str == null) {
|
||
|
throw new IllegalArgumentException("encodedName == null");
|
||
|
}
|
||
|
if (this.encodedQueryNamesAndValues == null) {
|
||
|
return this;
|
||
|
}
|
||
|
removeAllCanonicalQueryParameters(DeepLinkUri.canonicalize(str, " \"'<>#&=", true, true));
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
private void removeAllCanonicalQueryParameters(String str) {
|
||
|
for (int size = this.encodedQueryNamesAndValues.size() - 2; size >= 0; size -= 2) {
|
||
|
if (str.equals(this.encodedQueryNamesAndValues.get(size))) {
|
||
|
this.encodedQueryNamesAndValues.remove(size + 1);
|
||
|
this.encodedQueryNamesAndValues.remove(size);
|
||
|
if (this.encodedQueryNamesAndValues.isEmpty()) {
|
||
|
this.encodedQueryNamesAndValues = null;
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
final Builder fragment(String str) {
|
||
|
if (str == null) {
|
||
|
throw new IllegalArgumentException("fragment == null");
|
||
|
}
|
||
|
this.encodedFragment = DeepLinkUri.canonicalize(str, "", false, false);
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
final Builder encodedFragment(String str) {
|
||
|
if (str == null) {
|
||
|
throw new IllegalArgumentException("encodedFragment == null");
|
||
|
}
|
||
|
this.encodedFragment = DeepLinkUri.canonicalize(str, "", true, false);
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
final DeepLinkUri build() {
|
||
|
if (this.scheme == null) {
|
||
|
throw new IllegalStateException("scheme == null");
|
||
|
}
|
||
|
if (this.host == null) {
|
||
|
throw new IllegalStateException("host == null");
|
||
|
}
|
||
|
return new DeepLinkUri(this, this.templateUrl);
|
||
|
}
|
||
|
|
||
|
public final String toString() {
|
||
|
StringBuilder sb = new StringBuilder();
|
||
|
sb.append(this.scheme);
|
||
|
sb.append("://");
|
||
|
if (!this.encodedUsername.isEmpty() || !this.encodedPassword.isEmpty()) {
|
||
|
sb.append(this.encodedUsername);
|
||
|
if (!this.encodedPassword.isEmpty()) {
|
||
|
sb.append(':');
|
||
|
sb.append(this.encodedPassword);
|
||
|
}
|
||
|
sb.append('@');
|
||
|
}
|
||
|
if (this.host.indexOf(58) != -1) {
|
||
|
sb.append('[');
|
||
|
sb.append(this.host);
|
||
|
sb.append(']');
|
||
|
} else {
|
||
|
sb.append(this.host);
|
||
|
}
|
||
|
int effectivePort = effectivePort();
|
||
|
if (effectivePort != DeepLinkUri.defaultPort(this.scheme)) {
|
||
|
sb.append(':');
|
||
|
sb.append(effectivePort);
|
||
|
}
|
||
|
DeepLinkUri.pathSegmentsToString(sb, this.encodedPathSegments);
|
||
|
if (this.encodedQueryNamesAndValues != null) {
|
||
|
sb.append('?');
|
||
|
DeepLinkUri.namesAndValuesToQueryString(sb, this.encodedQueryNamesAndValues);
|
||
|
}
|
||
|
if (this.encodedFragment != null) {
|
||
|
sb.append('#');
|
||
|
sb.append(this.encodedFragment);
|
||
|
}
|
||
|
return sb.toString();
|
||
|
}
|
||
|
|
||
|
final ParseResult parse(DeepLinkUri deepLinkUri, String str, boolean z) {
|
||
|
int delimiterOffset;
|
||
|
boolean z2 = false;
|
||
|
int skipLeadingAsciiWhitespace = skipLeadingAsciiWhitespace(str, 0, str.length());
|
||
|
int skipTrailingAsciiWhitespace = skipTrailingAsciiWhitespace(str, skipLeadingAsciiWhitespace, str.length());
|
||
|
if (z) {
|
||
|
this.templateUrl = str;
|
||
|
}
|
||
|
int schemeDelimiterOffset = schemeDelimiterOffset(str, skipLeadingAsciiWhitespace, skipTrailingAsciiWhitespace, z);
|
||
|
if (schemeDelimiterOffset != -1) {
|
||
|
if (str.regionMatches(true, skipLeadingAsciiWhitespace, "https:", 0, 6)) {
|
||
|
this.scheme = "https";
|
||
|
skipLeadingAsciiWhitespace += 6;
|
||
|
} else if (str.regionMatches(true, skipLeadingAsciiWhitespace, "http:", 0, 5)) {
|
||
|
this.scheme = "http";
|
||
|
skipLeadingAsciiWhitespace += 5;
|
||
|
} else {
|
||
|
String substring = str.substring(skipLeadingAsciiWhitespace, schemeDelimiterOffset);
|
||
|
this.scheme = substring;
|
||
|
skipLeadingAsciiWhitespace += substring.length() + 1;
|
||
|
}
|
||
|
} else {
|
||
|
if (deepLinkUri == null) {
|
||
|
return ParseResult.MISSING_SCHEME;
|
||
|
}
|
||
|
this.scheme = deepLinkUri.scheme;
|
||
|
}
|
||
|
int slashCount = slashCount(str, skipLeadingAsciiWhitespace, skipTrailingAsciiWhitespace);
|
||
|
char c = '#';
|
||
|
if (slashCount >= 2 || deepLinkUri == null || !deepLinkUri.scheme.equals(this.scheme)) {
|
||
|
int i = skipLeadingAsciiWhitespace + slashCount;
|
||
|
boolean z3 = false;
|
||
|
while (true) {
|
||
|
delimiterOffset = DeepLinkUri.delimiterOffset(str, i, skipTrailingAsciiWhitespace, "@/\\?#");
|
||
|
char charAt = delimiterOffset != skipTrailingAsciiWhitespace ? str.charAt(delimiterOffset) : (char) 65535;
|
||
|
if (charAt == 65535 || charAt == c || charAt == '/' || charAt == '\\' || charAt == '?') {
|
||
|
break;
|
||
|
}
|
||
|
if (charAt == '@') {
|
||
|
if (z2) {
|
||
|
String str2 = this.encodedPassword;
|
||
|
String canonicalize = DeepLinkUri.canonicalize(str, i, delimiterOffset, " \"':;<=>@[]^`{}|/\\?#", true, false);
|
||
|
StringBuilder sb = new StringBuilder();
|
||
|
sb.append(str2);
|
||
|
sb.append("%40");
|
||
|
sb.append(canonicalize);
|
||
|
this.encodedPassword = sb.toString();
|
||
|
} else {
|
||
|
int delimiterOffset2 = DeepLinkUri.delimiterOffset(str, i, delimiterOffset, ":");
|
||
|
String canonicalize2 = DeepLinkUri.canonicalize(str, i, delimiterOffset2, " \"':;<=>@[]^`{}|/\\?#", true, false);
|
||
|
if (z3) {
|
||
|
String str3 = this.encodedUsername;
|
||
|
StringBuilder sb2 = new StringBuilder();
|
||
|
sb2.append(str3);
|
||
|
sb2.append("%40");
|
||
|
sb2.append(canonicalize2);
|
||
|
canonicalize2 = sb2.toString();
|
||
|
}
|
||
|
this.encodedUsername = canonicalize2;
|
||
|
if (delimiterOffset2 != delimiterOffset) {
|
||
|
this.encodedPassword = DeepLinkUri.canonicalize(str, delimiterOffset2 + 1, delimiterOffset, " \"':;<=>@[]^`{}|/\\?#", true, false);
|
||
|
z2 = true;
|
||
|
}
|
||
|
z3 = true;
|
||
|
}
|
||
|
i = delimiterOffset + 1;
|
||
|
}
|
||
|
c = '#';
|
||
|
}
|
||
|
int portColonOffset = portColonOffset(str, i, delimiterOffset);
|
||
|
int i2 = portColonOffset + 1;
|
||
|
if (i2 < delimiterOffset) {
|
||
|
this.host = canonicalizeHost(str, i, portColonOffset);
|
||
|
int parsePort = parsePort(str, i2, delimiterOffset);
|
||
|
this.port = parsePort;
|
||
|
if (parsePort == -1) {
|
||
|
return ParseResult.INVALID_PORT;
|
||
|
}
|
||
|
} else {
|
||
|
this.host = canonicalizeHost(str, i, portColonOffset);
|
||
|
this.port = DeepLinkUri.defaultPort(this.scheme);
|
||
|
}
|
||
|
if (this.host == null) {
|
||
|
return ParseResult.INVALID_HOST;
|
||
|
}
|
||
|
skipLeadingAsciiWhitespace = delimiterOffset;
|
||
|
} else {
|
||
|
this.encodedUsername = deepLinkUri.encodedUsername();
|
||
|
this.encodedPassword = deepLinkUri.encodedPassword();
|
||
|
this.host = deepLinkUri.host;
|
||
|
this.port = deepLinkUri.port;
|
||
|
this.encodedPathSegments.clear();
|
||
|
this.encodedPathSegments.addAll(deepLinkUri.encodedPathSegments());
|
||
|
if (skipLeadingAsciiWhitespace == skipTrailingAsciiWhitespace || str.charAt(skipLeadingAsciiWhitespace) == '#') {
|
||
|
encodedQuery(deepLinkUri.encodedQuery());
|
||
|
}
|
||
|
}
|
||
|
int delimiterOffset3 = DeepLinkUri.delimiterOffset(str, skipLeadingAsciiWhitespace, skipTrailingAsciiWhitespace, "?#");
|
||
|
resolvePath(str, skipLeadingAsciiWhitespace, delimiterOffset3);
|
||
|
if (delimiterOffset3 < skipTrailingAsciiWhitespace && str.charAt(delimiterOffset3) == '?') {
|
||
|
int delimiterOffset4 = DeepLinkUri.delimiterOffset(str, delimiterOffset3, skipTrailingAsciiWhitespace, "#");
|
||
|
this.encodedQueryNamesAndValues = DeepLinkUri.queryStringToNamesAndValues(DeepLinkUri.canonicalize(str, delimiterOffset3 + 1, delimiterOffset4, " \"'<>#", true, true));
|
||
|
delimiterOffset3 = delimiterOffset4;
|
||
|
}
|
||
|
if (delimiterOffset3 < skipTrailingAsciiWhitespace && str.charAt(delimiterOffset3) == '#') {
|
||
|
this.encodedFragment = DeepLinkUri.canonicalize(str, 1 + delimiterOffset3, skipTrailingAsciiWhitespace, "", true, false);
|
||
|
}
|
||
|
return ParseResult.SUCCESS;
|
||
|
}
|
||
|
|
||
|
private void resolvePath(String str, int i, int i2) {
|
||
|
if (i == i2) {
|
||
|
return;
|
||
|
}
|
||
|
char charAt = str.charAt(i);
|
||
|
if (charAt == '/' || charAt == '\\') {
|
||
|
this.encodedPathSegments.clear();
|
||
|
this.encodedPathSegments.add("");
|
||
|
i++;
|
||
|
} else {
|
||
|
List<String> list = this.encodedPathSegments;
|
||
|
list.set(list.size() - 1, "");
|
||
|
}
|
||
|
while (true) {
|
||
|
int i3 = i;
|
||
|
if (i3 >= i2) {
|
||
|
return;
|
||
|
}
|
||
|
i = DeepLinkUri.delimiterOffset(str, i3, i2, "/\\");
|
||
|
boolean z = i < i2;
|
||
|
push(str, i3, i, z, true);
|
||
|
if (z) {
|
||
|
i++;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void push(String str, int i, int i2, boolean z, boolean z2) {
|
||
|
String canonicalize = DeepLinkUri.canonicalize(str, i, i2, " \"<>^`{}|/\\?#", z2, false);
|
||
|
if (isDot(canonicalize)) {
|
||
|
return;
|
||
|
}
|
||
|
if (isDotDot(canonicalize)) {
|
||
|
pop();
|
||
|
return;
|
||
|
}
|
||
|
if (this.encodedPathSegments.get(r8.size() - 1).isEmpty()) {
|
||
|
this.encodedPathSegments.set(r8.size() - 1, canonicalize);
|
||
|
} else {
|
||
|
this.encodedPathSegments.add(canonicalize);
|
||
|
}
|
||
|
if (z) {
|
||
|
this.encodedPathSegments.add("");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private boolean isDot(String str) {
|
||
|
return str.equals(".") || str.equalsIgnoreCase("%2e");
|
||
|
}
|
||
|
|
||
|
private boolean isDotDot(String str) {
|
||
|
return str.equals("..") || str.equalsIgnoreCase("%2e.") || str.equalsIgnoreCase(".%2e") || str.equalsIgnoreCase("%2e%2e");
|
||
|
}
|
||
|
|
||
|
private void pop() {
|
||
|
if (this.encodedPathSegments.remove(r0.size() - 1).isEmpty() && !this.encodedPathSegments.isEmpty()) {
|
||
|
this.encodedPathSegments.set(r0.size() - 1, "");
|
||
|
} else {
|
||
|
this.encodedPathSegments.add("");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private int skipLeadingAsciiWhitespace(String str, int i, int i2) {
|
||
|
while (i < i2) {
|
||
|
char charAt = str.charAt(i);
|
||
|
if (charAt != '\t' && charAt != '\n' && charAt != '\f' && charAt != '\r' && charAt != ' ') {
|
||
|
return i;
|
||
|
}
|
||
|
i++;
|
||
|
}
|
||
|
return i2;
|
||
|
}
|
||
|
|
||
|
private int skipTrailingAsciiWhitespace(String str, int i, int i2) {
|
||
|
while (true) {
|
||
|
i2--;
|
||
|
if (i2 < i) {
|
||
|
return i;
|
||
|
}
|
||
|
char charAt = str.charAt(i2);
|
||
|
if (charAt != '\t' && charAt != '\n' && charAt != '\f' && charAt != '\r' && charAt != ' ') {
|
||
|
return i2 + 1;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private static int schemeDelimiterOffset(String str, int i, int i2, boolean z) {
|
||
|
if (i2 - i < 2) {
|
||
|
return -1;
|
||
|
}
|
||
|
char charAt = str.charAt(i);
|
||
|
if ((charAt < 'a' || charAt > 'z') && ((charAt < 'A' || charAt > 'Z') && z && charAt != '{')) {
|
||
|
return -1;
|
||
|
}
|
||
|
boolean z2 = charAt == '{';
|
||
|
for (int i3 = i + 1; i3 < i2; i3++) {
|
||
|
char charAt2 = str.charAt(i3);
|
||
|
if ((charAt2 < 'a' || charAt2 > 'z') && ((charAt2 < 'A' || charAt2 > 'Z') && !((charAt2 >= '0' && charAt2 <= '9') || charAt2 == '+' || charAt2 == '-' || charAt2 == '.' || ((charAt2 == '{' && z) || ((charAt2 == '}' && z) || z2))))) {
|
||
|
if (charAt2 == ':') {
|
||
|
return i3;
|
||
|
}
|
||
|
return -1;
|
||
|
}
|
||
|
if (charAt2 == '{') {
|
||
|
z2 = true;
|
||
|
}
|
||
|
if (charAt2 == '}') {
|
||
|
z2 = false;
|
||
|
}
|
||
|
}
|
||
|
return -1;
|
||
|
}
|
||
|
|
||
|
private static int slashCount(String str, int i, int i2) {
|
||
|
int i3 = 0;
|
||
|
while (i < i2) {
|
||
|
char charAt = str.charAt(i);
|
||
|
if (charAt != '\\' && charAt != '/') {
|
||
|
break;
|
||
|
}
|
||
|
i3++;
|
||
|
i++;
|
||
|
}
|
||
|
return i3;
|
||
|
}
|
||
|
|
||
|
private static int portColonOffset(String str, int i, int i2) {
|
||
|
while (i < i2) {
|
||
|
char charAt = str.charAt(i);
|
||
|
if (charAt == ':') {
|
||
|
return i;
|
||
|
}
|
||
|
if (charAt != '[') {
|
||
|
i++;
|
||
|
}
|
||
|
do {
|
||
|
i++;
|
||
|
if (i < i2) {
|
||
|
}
|
||
|
i++;
|
||
|
} while (str.charAt(i) != ']');
|
||
|
i++;
|
||
|
}
|
||
|
return i2;
|
||
|
}
|
||
|
|
||
|
private static String canonicalizeHost(String str, int i, int i2) {
|
||
|
String percentDecode = DeepLinkUri.percentDecode(str, i, i2);
|
||
|
if (percentDecode.startsWith("[") && percentDecode.endsWith("]")) {
|
||
|
InetAddress decodeIpv6 = decodeIpv6(percentDecode, 1, percentDecode.length() - 1);
|
||
|
if (decodeIpv6 == null) {
|
||
|
return null;
|
||
|
}
|
||
|
byte[] address = decodeIpv6.getAddress();
|
||
|
if (address.length == 16) {
|
||
|
return inet6AddressToAscii(address);
|
||
|
}
|
||
|
throw new AssertionError();
|
||
|
}
|
||
|
return domainToAscii(percentDecode);
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Code restructure failed: missing block: B:25:0x0073, code lost:
|
||
|
|
||
|
return null;
|
||
|
*/
|
||
|
/* JADX WARN: Removed duplicated region for block: B:15:0x004f */
|
||
|
/*
|
||
|
Code decompiled incorrectly, please refer to instructions dump.
|
||
|
To view partially-correct add '--show-bad-code' argument
|
||
|
*/
|
||
|
private static java.net.InetAddress decodeIpv6(java.lang.String r12, int r13, int r14) {
|
||
|
/*
|
||
|
r0 = 16
|
||
|
byte[] r1 = new byte[r0]
|
||
|
r2 = 0
|
||
|
r3 = -1
|
||
|
r4 = r2
|
||
|
r5 = r3
|
||
|
r6 = r5
|
||
|
L9:
|
||
|
r7 = 0
|
||
|
if (r13 >= r14) goto L74
|
||
|
if (r4 != r0) goto Lf
|
||
|
return r7
|
||
|
Lf:
|
||
|
int r8 = r13 + 2
|
||
|
r9 = 1
|
||
|
if (r8 > r14) goto L28
|
||
|
java.lang.String r10 = "::"
|
||
|
r11 = 2
|
||
|
boolean r10 = r12.regionMatches(r13, r10, r2, r11)
|
||
|
if (r10 == 0) goto L28
|
||
|
if (r5 == r3) goto L20
|
||
|
return r7
|
||
|
L20:
|
||
|
int r4 = r4 + 2
|
||
|
r5 = r4
|
||
|
if (r8 != r14) goto L26
|
||
|
goto L74
|
||
|
L26:
|
||
|
r6 = r8
|
||
|
goto L4b
|
||
|
L28:
|
||
|
if (r4 == 0) goto L4a
|
||
|
java.lang.String r8 = ":"
|
||
|
boolean r8 = r12.regionMatches(r13, r8, r2, r9)
|
||
|
if (r8 == 0) goto L35
|
||
|
int r13 = r13 + 1
|
||
|
goto L4a
|
||
|
L35:
|
||
|
java.lang.String r8 = "."
|
||
|
boolean r13 = r12.regionMatches(r13, r8, r2, r9)
|
||
|
if (r13 == 0) goto L49
|
||
|
int r13 = r4 + (-2)
|
||
|
boolean r12 = decodeIpv4Suffix(r12, r6, r14, r1, r13)
|
||
|
if (r12 != 0) goto L46
|
||
|
return r7
|
||
|
L46:
|
||
|
int r4 = r4 + 2
|
||
|
goto L74
|
||
|
L49:
|
||
|
return r7
|
||
|
L4a:
|
||
|
r6 = r13
|
||
|
L4b:
|
||
|
r8 = r2
|
||
|
r13 = r6
|
||
|
L4d:
|
||
|
if (r13 >= r14) goto L5f
|
||
|
char r10 = r12.charAt(r13)
|
||
|
int r10 = com.airbnb.deeplinkdispatch.DeepLinkUri.decodeHexDigit(r10)
|
||
|
if (r10 == r3) goto L5f
|
||
|
int r8 = r8 << 4
|
||
|
int r8 = r8 + r10
|
||
|
int r13 = r13 + 1
|
||
|
goto L4d
|
||
|
L5f:
|
||
|
int r10 = r13 - r6
|
||
|
if (r10 == 0) goto L73
|
||
|
r11 = 4
|
||
|
if (r10 > r11) goto L73
|
||
|
int r7 = r8 >>> 8
|
||
|
byte r7 = (byte) r7
|
||
|
r1[r4] = r7
|
||
|
int r7 = r4 + 2
|
||
|
byte r8 = (byte) r8
|
||
|
int r4 = r4 + r9
|
||
|
r1[r4] = r8
|
||
|
r4 = r7
|
||
|
goto L9
|
||
|
L73:
|
||
|
return r7
|
||
|
L74:
|
||
|
if (r4 == r0) goto L85
|
||
|
if (r5 != r3) goto L79
|
||
|
return r7
|
||
|
L79:
|
||
|
int r12 = r4 - r5
|
||
|
int r13 = 16 - r12
|
||
|
java.lang.System.arraycopy(r1, r5, r1, r13, r12)
|
||
|
int r0 = r0 - r4
|
||
|
int r0 = r0 + r5
|
||
|
java.util.Arrays.fill(r1, r5, r0, r2)
|
||
|
L85:
|
||
|
java.net.InetAddress r12 = java.net.InetAddress.getByAddress(r1) // Catch: java.net.UnknownHostException -> L8a
|
||
|
return r12
|
||
|
L8a:
|
||
|
java.lang.AssertionError r12 = new java.lang.AssertionError
|
||
|
r12.<init>()
|
||
|
throw r12
|
||
|
*/
|
||
|
throw new UnsupportedOperationException("Method not decompiled: com.airbnb.deeplinkdispatch.DeepLinkUri.Builder.decodeIpv6(java.lang.String, int, int):java.net.InetAddress");
|
||
|
}
|
||
|
|
||
|
private static boolean decodeIpv4Suffix(String str, int i, int i2, byte[] bArr, int i3) {
|
||
|
int i4 = i3;
|
||
|
while (i < i2) {
|
||
|
if (i4 == bArr.length) {
|
||
|
return false;
|
||
|
}
|
||
|
if (i4 != i3) {
|
||
|
if (str.charAt(i) != '.') {
|
||
|
return false;
|
||
|
}
|
||
|
i++;
|
||
|
}
|
||
|
int i5 = i;
|
||
|
int i6 = 0;
|
||
|
while (i5 < i2) {
|
||
|
char charAt = str.charAt(i5);
|
||
|
if (charAt < '0' || charAt > '9') {
|
||
|
break;
|
||
|
}
|
||
|
if ((i6 == 0 && i != i5) || (i6 = ((i6 * 10) + charAt) - 48) > 255) {
|
||
|
return false;
|
||
|
}
|
||
|
i5++;
|
||
|
}
|
||
|
if (i5 - i == 0) {
|
||
|
return false;
|
||
|
}
|
||
|
bArr[i4] = (byte) i6;
|
||
|
i4++;
|
||
|
i = i5;
|
||
|
}
|
||
|
return i4 == i3 + 4;
|
||
|
}
|
||
|
|
||
|
private static String domainToAscii(String str) {
|
||
|
try {
|
||
|
Set<String> placeHolders = DeepLinkUri.getPlaceHolders(str);
|
||
|
HashMap hashMap = new HashMap(placeHolders.size());
|
||
|
int i = 0;
|
||
|
for (String str2 : placeHolders) {
|
||
|
StringBuilder sb = new StringBuilder();
|
||
|
sb.append(i);
|
||
|
String obj = sb.toString();
|
||
|
str = str.replace(str2, obj);
|
||
|
hashMap.put(str2, obj);
|
||
|
i++;
|
||
|
}
|
||
|
String lowerCase = IDN.toASCII(str).toLowerCase(Locale.US);
|
||
|
for (Map.Entry entry : hashMap.entrySet()) {
|
||
|
lowerCase = lowerCase.replace((CharSequence) entry.getValue(), (CharSequence) entry.getKey());
|
||
|
}
|
||
|
if (lowerCase.isEmpty() || lowerCase == null) {
|
||
|
return null;
|
||
|
}
|
||
|
if (containsInvalidHostnameAsciiCodes(lowerCase)) {
|
||
|
return null;
|
||
|
}
|
||
|
return lowerCase;
|
||
|
} catch (IllegalArgumentException unused) {
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private static boolean containsInvalidHostnameAsciiCodes(String str) {
|
||
|
for (int i = 0; i < str.length(); i++) {
|
||
|
char charAt = str.charAt(i);
|
||
|
if (charAt <= 31 || charAt >= 127 || " #%/:?@[\\]".indexOf(charAt) != -1) {
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
private static String inet6AddressToAscii(byte[] bArr) {
|
||
|
int i = -1;
|
||
|
int i2 = 0;
|
||
|
int i3 = 0;
|
||
|
int i4 = 0;
|
||
|
while (i3 < bArr.length) {
|
||
|
int i5 = i3;
|
||
|
while (i5 < 16 && bArr[i5] == 0 && bArr[i5 + 1] == 0) {
|
||
|
i5 += 2;
|
||
|
}
|
||
|
int i6 = i5 - i3;
|
||
|
if (i6 > i4) {
|
||
|
i = i3;
|
||
|
i4 = i6;
|
||
|
}
|
||
|
i3 = i5 + 2;
|
||
|
}
|
||
|
C15111ghZ c15111ghZ = new C15111ghZ();
|
||
|
while (i2 < bArr.length) {
|
||
|
if (i2 == i) {
|
||
|
c15111ghZ.b(58);
|
||
|
i2 += i4;
|
||
|
if (i2 == 16) {
|
||
|
c15111ghZ.b(58);
|
||
|
}
|
||
|
} else {
|
||
|
if (i2 > 0) {
|
||
|
c15111ghZ.b(58);
|
||
|
}
|
||
|
c15111ghZ.l(((bArr[i2] & UnsignedBytes.MAX_VALUE) << 8) | (bArr[i2 + 1] & UnsignedBytes.MAX_VALUE));
|
||
|
i2 += 2;
|
||
|
}
|
||
|
}
|
||
|
return c15111ghZ.b(c15111ghZ.c, gdP.a);
|
||
|
}
|
||
|
|
||
|
private static int parsePort(String str, int i, int i2) {
|
||
|
try {
|
||
|
int parseInt = Integer.parseInt(DeepLinkUri.canonicalize(str, i, i2, "", false, false));
|
||
|
if (parseInt <= 0 || parseInt > 65535) {
|
||
|
return -1;
|
||
|
}
|
||
|
return parseInt;
|
||
|
} catch (NumberFormatException unused) {
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: private */
|
||
|
public static int delimiterOffset(String str, int i, int i2, String str2) {
|
||
|
while (i < i2) {
|
||
|
if (str2.indexOf(str.charAt(i)) != -1) {
|
||
|
return i;
|
||
|
}
|
||
|
i++;
|
||
|
}
|
||
|
return i2;
|
||
|
}
|
||
|
|
||
|
static String percentDecode(String str) {
|
||
|
return percentDecode(str, 0, str.length());
|
||
|
}
|
||
|
|
||
|
private List<String> percentDecode(List<String> list) {
|
||
|
ArrayList arrayList = new ArrayList(list.size());
|
||
|
Iterator<String> it = list.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
String next = it.next();
|
||
|
arrayList.add(next != null ? percentDecode(next) : null);
|
||
|
}
|
||
|
return Collections.unmodifiableList(arrayList);
|
||
|
}
|
||
|
|
||
|
static String percentDecode(String str, int i, int i2) {
|
||
|
for (int i3 = i; i3 < i2; i3++) {
|
||
|
if (str.charAt(i3) == '%') {
|
||
|
C15111ghZ c15111ghZ = new C15111ghZ();
|
||
|
c15111ghZ.c(str, i, i3);
|
||
|
percentDecode(c15111ghZ, str, i3, i2);
|
||
|
return c15111ghZ.b(c15111ghZ.c, gdP.a);
|
||
|
}
|
||
|
}
|
||
|
return str.substring(i, i2);
|
||
|
}
|
||
|
|
||
|
static void percentDecode(C15111ghZ c15111ghZ, String str, int i, int i2) {
|
||
|
int i3;
|
||
|
while (i < i2) {
|
||
|
int codePointAt = str.codePointAt(i);
|
||
|
if (codePointAt == 37 && (i3 = i + 2) < i2) {
|
||
|
int decodeHexDigit = decodeHexDigit(str.charAt(i + 1));
|
||
|
int decodeHexDigit2 = decodeHexDigit(str.charAt(i3));
|
||
|
if (decodeHexDigit != -1 && decodeHexDigit2 != -1) {
|
||
|
c15111ghZ.b((decodeHexDigit << 4) + decodeHexDigit2);
|
||
|
i = i3;
|
||
|
i += Character.charCount(codePointAt);
|
||
|
}
|
||
|
}
|
||
|
c15111ghZ.i(codePointAt);
|
||
|
i += Character.charCount(codePointAt);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
static String canonicalize(String str, int i, int i2, String str2, boolean z, boolean z2) {
|
||
|
int i3 = i;
|
||
|
while (i3 < i2) {
|
||
|
int codePointAt = str.codePointAt(i3);
|
||
|
if (codePointAt >= 32 && codePointAt < 127 && str2.indexOf(codePointAt) == -1 && ((codePointAt != 37 || z) && (!z2 || codePointAt != 43))) {
|
||
|
i3 += Character.charCount(codePointAt);
|
||
|
} else {
|
||
|
C15111ghZ c15111ghZ = new C15111ghZ();
|
||
|
c15111ghZ.c(str, i, i3);
|
||
|
canonicalize(c15111ghZ, str, i3, i2, str2, z, z2);
|
||
|
return c15111ghZ.b(c15111ghZ.c, gdP.a);
|
||
|
}
|
||
|
}
|
||
|
return str.substring(i, i2);
|
||
|
}
|
||
|
|
||
|
static void canonicalize(C15111ghZ c15111ghZ, String str, int i, int i2, String str2, boolean z, boolean z2) {
|
||
|
C15111ghZ c15111ghZ2 = null;
|
||
|
while (i < i2) {
|
||
|
int codePointAt = str.codePointAt(i);
|
||
|
if (!z || (codePointAt != 9 && codePointAt != 10 && codePointAt != 12 && codePointAt != 13)) {
|
||
|
if (z2 && codePointAt == 43) {
|
||
|
String str3 = z ? "%20" : "%2B";
|
||
|
C14957gcv.e(str3, "");
|
||
|
c15111ghZ.c(str3, 0, str3.length());
|
||
|
} else if (codePointAt < 32 || codePointAt >= 127 || str2.indexOf(codePointAt) != -1 || (codePointAt == 37 && !z)) {
|
||
|
if (c15111ghZ2 == null) {
|
||
|
c15111ghZ2 = new C15111ghZ();
|
||
|
}
|
||
|
c15111ghZ2.i(codePointAt);
|
||
|
while (c15111ghZ2.c != 0) {
|
||
|
try {
|
||
|
byte f = c15111ghZ2.f();
|
||
|
c15111ghZ.b(37);
|
||
|
char[] cArr = HEX_DIGITS;
|
||
|
c15111ghZ.b((int) cArr[((f & UnsignedBytes.MAX_VALUE) >> 4) & 15]);
|
||
|
c15111ghZ.b((int) cArr[f & 15]);
|
||
|
} catch (EOFException unused) {
|
||
|
System.err.println("Unable to canonicalize deeplink url!");
|
||
|
}
|
||
|
}
|
||
|
} else {
|
||
|
c15111ghZ.i(codePointAt);
|
||
|
}
|
||
|
}
|
||
|
i += Character.charCount(codePointAt);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
static String canonicalize(String str, String str2, boolean z, boolean z2) {
|
||
|
return canonicalize(str, 0, str.length(), str2, z, z2);
|
||
|
}
|
||
|
|
||
|
final String username() {
|
||
|
return this.username;
|
||
|
}
|
||
|
|
||
|
public final String toTemplateString() {
|
||
|
return this.urlTemplate;
|
||
|
}
|
||
|
|
||
|
public final String toString() {
|
||
|
return this.url;
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public final String scheme() {
|
||
|
return this.scheme;
|
||
|
}
|
||
|
|
||
|
final int port() {
|
||
|
return this.port;
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public final List<String> pathSegments() {
|
||
|
return this.pathSegments;
|
||
|
}
|
||
|
|
||
|
final String password() {
|
||
|
return this.password;
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public final String host() {
|
||
|
return this.host;
|
||
|
}
|
||
|
|
||
|
final List<String> getQueryNamesAndValues() {
|
||
|
return this.queryNamesAndValues;
|
||
|
}
|
||
|
|
||
|
final String fragment() {
|
||
|
return this.fragment;
|
||
|
}
|
||
|
}
|