Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ IsValidStrict()

static unsafe bool System.IPv6AddressHelper.IsValidStrict ( char * name,
int start,
ref int end )
inlinestaticpackage

Definition at line 53 of file IPv6AddressHelper.cs.

54 {
55 int num = 0;
56 int num2 = 0;
57 bool flag = false;
58 bool flag2 = false;
59 bool flag3 = true;
60 int start2 = 1;
61 bool flag4 = false;
62 if (start < end && name[start] == '[')
63 {
64 start++;
65 flag4 = true;
66 }
67 if (name[start] == ':' && (start + 1 >= end || name[start + 1] != ':'))
68 {
69 return false;
70 }
71 for (int i = start; i < end; i++)
72 {
73 if (Uri.IsHexDigit(name[i]))
74 {
75 num2++;
76 flag3 = false;
77 continue;
78 }
79 if (num2 > 4)
80 {
81 return false;
82 }
83 if (num2 != 0)
84 {
85 num++;
86 start2 = i - num2;
87 num2 = 0;
88 }
89 char c = name[i];
90 if ((uint)c <= 46u)
91 {
92 if (c != '%')
93 {
94 if (c != '.')
95 {
96 goto IL_01e6;
97 }
98 if (flag2)
99 {
100 return false;
101 }
102 i = end;
103 if (!System.IPv4AddressHelper.IsValid(name, start2, ref i, allowIPv6: true, notImplicitFile: false, unknownScheme: false))
104 {
105 return false;
106 }
107 num++;
108 start2 = i - num2;
109 num2 = 0;
110 flag2 = true;
111 i--;
112 }
113 else
114 {
115 while (i + 1 < end)
116 {
117 i++;
118 if (name[i] == ']')
119 {
120 goto IL_00f1;
121 }
122 if (name[i] != '/')
123 {
124 continue;
125 }
126 goto IL_01b4;
127 }
128 }
129 }
130 else
131 {
132 if (c == '/')
133 {
134 goto IL_01b4;
135 }
136 if (c != ':')
137 {
138 if (c == ']')
139 {
140 goto IL_00f1;
141 }
142 goto IL_01e6;
143 }
144 if (i > 0 && name[i - 1] == ':')
145 {
146 if (flag)
147 {
148 return false;
149 }
150 flag = true;
151 flag3 = false;
152 }
153 else
154 {
155 flag3 = true;
156 }
157 }
158 num2 = 0;
159 continue;
160 IL_01e6:
161 return false;
162 IL_01b4:
163 return false;
164 IL_00f1:
165 if (!flag4)
166 {
167 return false;
168 }
169 flag4 = false;
170 if (i + 1 < end && name[i + 1] != ':')
171 {
172 return false;
173 }
174 if (i + 3 < end && name[i + 2] == '0' && name[i + 3] == 'x')
175 {
176 for (i += 4; i < end; i++)
177 {
178 if (!Uri.IsHexDigit(name[i]))
179 {
180 return false;
181 }
182 }
183 continue;
184 }
185 for (i += 2; i < end; i++)
186 {
187 if (name[i] < '0' || name[i] > '9')
188 {
189 return false;
190 }
191 }
192 }
193 if (num2 != 0)
194 {
195 if (num2 > 4)
196 {
197 return false;
198 }
199 num++;
200 }
201 if (!flag3 && (flag ? (num < 8) : (num == 8)))
202 {
203 return !flag4;
204 }
205 return false;
206 }
static unsafe bool IsValid(char *name, int start, ref int end, bool allowIPv6, bool notImplicitFile, bool unknownScheme)

References System.Uri.IsHexDigit(), System.IPv4AddressHelper.IsValid(), and System.start.

Referenced by System.Net.IPAddressParser.Ipv6StringToAddress().