Rabbit-R1/switch port/smali/smali_classes3/okhttp3/internal/HostnamesKt.smali

843 lines
15 KiB
Smali
Raw Normal View History

2024-05-21 16:08:36 -05:00
.class public final Lokhttp3/internal/HostnamesKt;
.super Ljava/lang/Object;
.source "hostnames.kt"
# annotations
.annotation runtime Lkotlin/Metadata;
bv = {
0x1,
0x0,
0x3
}
d1 = {
"\u0000&\n\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0010\u000e\n\u0000\n\u0002\u0010\u0008\n\u0002\u0008\u0002\n\u0002\u0010\u0012\n\u0002\u0008\u0002\n\u0002\u0018\u0002\n\u0002\u0008\u0004\u001a0\u0010\u0000\u001a\u00020\u00012\u0006\u0010\u0002\u001a\u00020\u00032\u0006\u0010\u0004\u001a\u00020\u00052\u0006\u0010\u0006\u001a\u00020\u00052\u0006\u0010\u0007\u001a\u00020\u00082\u0006\u0010\t\u001a\u00020\u0005H\u0002\u001a\"\u0010\n\u001a\u0004\u0018\u00010\u000b2\u0006\u0010\u0002\u001a\u00020\u00032\u0006\u0010\u0004\u001a\u00020\u00052\u0006\u0010\u0006\u001a\u00020\u0005H\u0002\u001a\u0010\u0010\u000c\u001a\u00020\u00032\u0006\u0010\u0007\u001a\u00020\u0008H\u0002\u001a\u000c\u0010\r\u001a\u00020\u0001*\u00020\u0003H\u0002\u001a\u000c\u0010\u000e\u001a\u0004\u0018\u00010\u0003*\u00020\u0003\u00a8\u0006\u000f"
}
d2 = {
"decodeIpv4Suffix",
"",
"input",
"",
"pos",
"",
"limit",
"address",
"",
"addressOffset",
"decodeIpv6",
"Ljava/net/InetAddress;",
"inet6AddressToAscii",
"containsInvalidHostnameAsciiCodes",
"toCanonicalHost",
"okhttp"
}
k = 0x2
mv = {
0x1,
0x4,
0x0
}
.end annotation
# direct methods
.method private static final containsInvalidHostnameAsciiCodes(Ljava/lang/String;)Z
.locals 10
.line 65
invoke-virtual {p0}, Ljava/lang/String;->length()I
move-result v0
const/4 v1, 0x0
move v2, v1
:goto_0
if-ge v2, v0, :cond_3
.line 66
invoke-virtual {p0, v2}, Ljava/lang/String;->charAt(I)C
move-result v4
const/16 v3, 0x1f
.line 70
invoke-static {v4, v3}, Lkotlin/jvm/internal/Intrinsics;->compare(II)I
move-result v3
const/4 v9, 0x1
if-lez v3, :cond_2
const/16 v3, 0x7f
invoke-static {v4, v3}, Lkotlin/jvm/internal/Intrinsics;->compare(II)I
move-result v3
if-ltz v3, :cond_0
goto :goto_1
:cond_0
const-string v3, " #%/:?@[\\]"
.line 76
check-cast v3, Ljava/lang/CharSequence;
const/4 v5, 0x0
const/4 v6, 0x0
const/4 v7, 0x6
const/4 v8, 0x0
invoke-static/range {v3 .. v8}, Lkotlin/text/StringsKt;->indexOf$default(Ljava/lang/CharSequence;CIZILjava/lang/Object;)I
move-result v3
const/4 v4, -0x1
if-eq v3, v4, :cond_1
return v9
:cond_1
add-int/lit8 v2, v2, 0x1
goto :goto_0
:cond_2
:goto_1
return v9
:cond_3
return v1
.end method
.method private static final decodeIpv4Suffix(Ljava/lang/String;II[BI)Z
.locals 7
move v0, p4
:goto_0
const/4 v1, 0x0
if-ge p1, p2, :cond_8
.line 163
array-length v2, p3
if-ne v0, v2, :cond_0
return v1
:cond_0
if-eq v0, p4, :cond_2
.line 167
invoke-virtual {p0, p1}, Ljava/lang/String;->charAt(I)C
move-result v2
const/16 v3, 0x2e
if-eq v2, v3, :cond_1
return v1
:cond_1
add-int/lit8 p1, p1, 0x1
:cond_2
move v2, p1
move v3, v1
:goto_1
if-ge v2, p2, :cond_6
.line 175
invoke-virtual {p0, v2}, Ljava/lang/String;->charAt(I)C
move-result v4
const/16 v5, 0x30
.line 176
invoke-static {v4, v5}, Lkotlin/jvm/internal/Intrinsics;->compare(II)I
move-result v6
if-ltz v6, :cond_6
const/16 v6, 0x39
invoke-static {v4, v6}, Lkotlin/jvm/internal/Intrinsics;->compare(II)I
move-result v6
if-lez v6, :cond_3
goto :goto_2
:cond_3
if-nez v3, :cond_4
if-eq p1, v2, :cond_4
return v1
:cond_4
mul-int/lit8 v3, v3, 0xa
add-int/2addr v3, v4
sub-int/2addr v3, v5
const/16 v4, 0xff
if-le v3, v4, :cond_5
return v1
:cond_5
add-int/lit8 v2, v2, 0x1
goto :goto_1
:cond_6
:goto_2
sub-int p1, v2, p1
if-nez p1, :cond_7
return v1
:cond_7
add-int/lit8 p1, v0, 0x1
int-to-byte v1, v3
.line 186
aput-byte v1, p3, v0
move v0, p1
move p1, v2
goto :goto_0
:cond_8
add-int/lit8 p4, p4, 0x4
if-ne v0, p4, :cond_9
const/4 v1, 0x1
:cond_9
return v1
.end method
.method private static final decodeIpv6(Ljava/lang/String;II)Ljava/net/InetAddress;
.locals 18
move-object/from16 v6, p0
move/from16 v7, p2
const/16 v8, 0x10
new-array v9, v8, [B
const/4 v11, -0x1
move/from16 v12, p1
move v14, v11
move v15, v14
const/4 v13, 0x0
:goto_0
const/16 v16, 0x0
if-ge v12, v7, :cond_c
if-ne v13, v8, :cond_0
return-object v16
:cond_0
add-int/lit8 v5, v12, 0x2
if-gt v5, v7, :cond_3
const-string v1, "::"
const/4 v3, 0x0
const/4 v4, 0x4
const/16 v17, 0x0
move-object/from16 v0, p0
move v2, v12
move v10, v5
move-object/from16 v5, v17
.line 95
invoke-static/range {v0 .. v5}, Lkotlin/text/StringsKt;->startsWith$default(Ljava/lang/String;Ljava/lang/String;IZILjava/lang/Object;)Z
move-result v0
if-eqz v0, :cond_3
if-eq v14, v11, :cond_1
return-object v16
:cond_1
add-int/lit8 v13, v13, 0x2
if-ne v10, v7, :cond_2
move v14, v13
goto/16 :goto_6
:cond_2
move v15, v10
move v14, v13
goto :goto_2
:cond_3
if-eqz v13, :cond_7
const-string v1, ":"
const/4 v3, 0x0
const/4 v4, 0x4
const/4 v5, 0x0
move-object/from16 v0, p0
move v2, v12
.line 104
invoke-static/range {v0 .. v5}, Lkotlin/text/StringsKt;->startsWith$default(Ljava/lang/String;Ljava/lang/String;IZILjava/lang/Object;)Z
move-result v0
if-eqz v0, :cond_4
add-int/lit8 v12, v12, 0x1
goto :goto_1
:cond_4
const-string v1, "."
const/4 v3, 0x0
const/4 v4, 0x4
const/4 v5, 0x0
move-object/from16 v0, p0
move v2, v12
.line 106
invoke-static/range {v0 .. v5}, Lkotlin/text/StringsKt;->startsWith$default(Ljava/lang/String;Ljava/lang/String;IZILjava/lang/Object;)Z
move-result v0
if-eqz v0, :cond_6
add-int/lit8 v0, v13, -0x2
.line 108
invoke-static {v6, v15, v7, v9, v0}, Lokhttp3/internal/HostnamesKt;->decodeIpv4Suffix(Ljava/lang/String;II[BI)Z
move-result v0
if-nez v0, :cond_5
return-object v16
:cond_5
add-int/lit8 v13, v13, 0x2
goto :goto_6
:cond_6
return-object v16
:cond_7
:goto_1
move v15, v12
:goto_2
move v12, v15
const/4 v0, 0x0
:goto_3
if-ge v12, v7, :cond_9
.line 120
invoke-virtual {v6, v12}, Ljava/lang/String;->charAt(I)C
move-result v1
invoke-static {v1}, Lokhttp3/internal/Util;->parseHexDigit(C)I
move-result v1
if-ne v1, v11, :cond_8
goto :goto_4
:cond_8
shl-int/lit8 v0, v0, 0x4
add-int/2addr v0, v1
add-int/lit8 v12, v12, 0x1
goto :goto_3
:cond_9
:goto_4
sub-int v1, v12, v15
if-eqz v1, :cond_b
const/4 v2, 0x4
if-le v1, v2, :cond_a
goto :goto_5
:cond_a
add-int/lit8 v1, v13, 0x1
ushr-int/lit8 v2, v0, 0x8
and-int/lit16 v2, v2, 0xff
int-to-byte v2, v2
.line 129
aput-byte v2, v9, v13
add-int/lit8 v13, v13, 0x2
and-int/lit16 v0, v0, 0xff
int-to-byte v0, v0
.line 130
aput-byte v0, v9, v1
goto/16 :goto_0
:cond_b
:goto_5
return-object v16
:cond_c
:goto_6
if-eq v13, v8, :cond_e
if-ne v14, v11, :cond_d
return-object v16
:cond_d
sub-int v0, v13, v14
rsub-int/lit8 v1, v0, 0x10
.line 144
invoke-static {v9, v14, v9, v1, v0}, Ljava/lang/System;->arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V
sub-int/2addr v8, v13
add-int/2addr v8, v14
const/4 v0, 0x0
int-to-byte v0, v0
.line 145
invoke-static {v9, v14, v8, v0}, Ljava/util/Arrays;->fill([BIIB)V
.line 148
:cond_e
invoke-static {v9}, Ljava/net/InetAddress;->getByAddress([B)Ljava/net/InetAddress;
move-result-object v0
return-object v0
.end method
.method private static final inet6AddressToAscii([B)Ljava/lang/String;
.locals 8
const/4 v0, -0x1
const/4 v1, 0x0
move v2, v1
move v3, v2
.line 202
:goto_0
array-length v4, p0
const/16 v5, 0x10
if-ge v2, v4, :cond_2
move v4, v2
:goto_1
if-ge v4, v5, :cond_0
.line 204
aget-byte v6, p0, v4
if-nez v6, :cond_0
add-int/lit8 v6, v4, 0x1
aget-byte v6, p0, v6
if-nez v6, :cond_0
add-int/lit8 v4, v4, 0x2
goto :goto_1
:cond_0
sub-int v5, v4, v2
if-le v5, v3, :cond_1
const/4 v6, 0x4
if-lt v5, v6, :cond_1
move v0, v2
move v3, v5
:cond_1
add-int/lit8 v2, v4, 0x2
goto :goto_0
.line 217
:cond_2
new-instance v2, Lokio/Buffer;
invoke-direct {v2}, Lokio/Buffer;-><init>()V
.line 219
:cond_3
:goto_2
array-length v4, p0
if-ge v1, v4, :cond_6
const/16 v4, 0x3a
if-ne v1, v0, :cond_4
.line 221
invoke-virtual {v2, v4}, Lokio/Buffer;->writeByte(I)Lokio/Buffer;
add-int/2addr v1, v3
if-ne v1, v5, :cond_3
.line 223
invoke-virtual {v2, v4}, Lokio/Buffer;->writeByte(I)Lokio/Buffer;
goto :goto_2
:cond_4
if-lez v1, :cond_5
.line 225
invoke-virtual {v2, v4}, Lokio/Buffer;->writeByte(I)Lokio/Buffer;
.line 226
:cond_5
aget-byte v4, p0, v1
const/16 v6, 0xff
invoke-static {v4, v6}, Lokhttp3/internal/Util;->and(BI)I
move-result v4
shl-int/lit8 v4, v4, 0x8
add-int/lit8 v7, v1, 0x1
aget-byte v7, p0, v7
invoke-static {v7, v6}, Lokhttp3/internal/Util;->and(BI)I
move-result v6
or-int/2addr v4, v6
int-to-long v6, v4
.line 227
invoke-virtual {v2, v6, v7}, Lokio/Buffer;->writeHexadecimalUnsignedLong(J)Lokio/Buffer;
add-int/lit8 v1, v1, 0x2
goto :goto_2
.line 231
:cond_6
invoke-virtual {v2}, Lokio/Buffer;->readUtf8()Ljava/lang/String;
move-result-object p0
return-object p0
.end method
.method public static final toCanonicalHost(Ljava/lang/String;)Ljava/lang/String;
.locals 5
const-string v0, "$this$toCanonicalHost"
invoke-static {p0, v0}, Lkotlin/jvm/internal/Intrinsics;->checkNotNullParameter(Ljava/lang/Object;Ljava/lang/String;)V
.line 36
move-object v0, p0
check-cast v0, Ljava/lang/CharSequence;
const-string v1, ":"
check-cast v1, Ljava/lang/CharSequence;
const/4 v2, 0x0
const/4 v3, 0x2
const/4 v4, 0x0
invoke-static {v0, v1, v2, v3, v4}, Lkotlin/text/StringsKt;->contains$default(Ljava/lang/CharSequence;Ljava/lang/CharSequence;ZILjava/lang/Object;)Z
move-result v0
if-eqz v0, :cond_4
const-string v0, "["
.line 38
invoke-static {p0, v0, v2, v3, v4}, Lkotlin/text/StringsKt;->startsWith$default(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z
move-result v0
if-eqz v0, :cond_0
const-string v0, "]"
invoke-static {p0, v0, v2, v3, v4}, Lkotlin/text/StringsKt;->endsWith$default(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z
move-result v0
if-eqz v0, :cond_0
.line 39
invoke-virtual {p0}, Ljava/lang/String;->length()I
move-result v0
const/4 v1, 0x1
sub-int/2addr v0, v1
invoke-static {p0, v1, v0}, Lokhttp3/internal/HostnamesKt;->decodeIpv6(Ljava/lang/String;II)Ljava/net/InetAddress;
move-result-object v0
goto :goto_0
.line 41
:cond_0
invoke-virtual {p0}, Ljava/lang/String;->length()I
move-result v0
invoke-static {p0, v2, v0}, Lokhttp3/internal/HostnamesKt;->decodeIpv6(Ljava/lang/String;II)Ljava/net/InetAddress;
move-result-object v0
:goto_0
if-eqz v0, :cond_3
.line 43
invoke-virtual {v0}, Ljava/net/InetAddress;->getAddress()[B
move-result-object v1
.line 44
array-length v2, v1
const/16 v3, 0x10
if-ne v2, v3, :cond_1
const-string p0, "address"
invoke-static {v1, p0}, Lkotlin/jvm/internal/Intrinsics;->checkNotNullExpressionValue(Ljava/lang/Object;Ljava/lang/String;)V
invoke-static {v1}, Lokhttp3/internal/HostnamesKt;->inet6AddressToAscii([B)Ljava/lang/String;
move-result-object p0
return-object p0
.line 45
:cond_1
array-length v1, v1
const/4 v2, 0x4
if-ne v1, v2, :cond_2
invoke-virtual {v0}, Ljava/net/InetAddress;->getHostAddress()Ljava/lang/String;
move-result-object p0
return-object p0
.line 46
:cond_2
new-instance v0, Ljava/lang/AssertionError;
new-instance v1, Ljava/lang/StringBuilder;
const-string v2, "Invalid IPv6 address: \'"
invoke-direct {v1, v2}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
invoke-virtual {v1, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object p0
const/16 v1, 0x27
invoke-virtual {p0, v1}, Ljava/lang/StringBuilder;->append(C)Ljava/lang/StringBuilder;
move-result-object p0
invoke-virtual {p0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object p0
invoke-direct {v0, p0}, Ljava/lang/AssertionError;-><init>(Ljava/lang/Object;)V
check-cast v0, Ljava/lang/Throwable;
throw v0
:cond_3
return-object v4
.line 50
:cond_4
:try_start_0
invoke-static {p0}, Ljava/net/IDN;->toASCII(Ljava/lang/String;)Ljava/lang/String;
move-result-object p0
const-string v0, "IDN.toASCII(host)"
invoke-static {p0, v0}, Lkotlin/jvm/internal/Intrinsics;->checkNotNullExpressionValue(Ljava/lang/Object;Ljava/lang/String;)V
sget-object v0, Ljava/util/Locale;->US:Ljava/util/Locale;
const-string v1, "Locale.US"
invoke-static {v0, v1}, Lkotlin/jvm/internal/Intrinsics;->checkNotNullExpressionValue(Ljava/lang/Object;Ljava/lang/String;)V
if-eqz p0, :cond_7
invoke-virtual {p0, v0}, Ljava/lang/String;->toLowerCase(Ljava/util/Locale;)Ljava/lang/String;
move-result-object p0
const-string v0, "(this as java.lang.String).toLowerCase(locale)"
invoke-static {p0, v0}, Lkotlin/jvm/internal/Intrinsics;->checkNotNullExpressionValue(Ljava/lang/Object;Ljava/lang/String;)V
.line 51
move-object v0, p0
check-cast v0, Ljava/lang/CharSequence;
invoke-interface {v0}, Ljava/lang/CharSequence;->length()I
move-result v0
if-nez v0, :cond_5
return-object v4
.line 54
:cond_5
invoke-static {p0}, Lokhttp3/internal/HostnamesKt;->containsInvalidHostnameAsciiCodes(Ljava/lang/String;)Z
move-result v0
if-eqz v0, :cond_6
goto :goto_1
:cond_6
move-object v4, p0
:goto_1
return-object v4
.line 50
:cond_7
new-instance p0, Ljava/lang/NullPointerException;
const-string v0, "null cannot be cast to non-null type java.lang.String"
invoke-direct {p0, v0}, Ljava/lang/NullPointerException;-><init>(Ljava/lang/String;)V
throw p0
:try_end_0
.catch Ljava/lang/IllegalArgumentException; {:try_start_0 .. :try_end_0} :catch_0
:catch_0
return-object v4
.end method