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

◆ ParseRemaining()

unsafe void System.Uri.ParseRemaining ( )
inlineprivate

Definition at line 2215 of file Uri.cs.

2216 {
2217 EnsureUriInfo();
2218 Flags flags = Flags.Zero;
2219 if (!UserDrivenParsing)
2220 {
2221 bool flag = (_flags & (Flags.HasUnicode | Flags.RestUnicodeNormalized)) == Flags.HasUnicode;
2222 int scheme = _info.Offset.Scheme;
2223 int length = _string.Length;
2224 Check check = Check.None;
2225 UriSyntaxFlags flags2 = _syntax.Flags;
2226 fixed (char* ptr = _string)
2227 {
2229 if (IsImplicitFile)
2230 {
2231 flags |= Flags.SchemeNotCanonical;
2232 }
2233 else
2234 {
2235 string schemeName = _syntax.SchemeName;
2236 int i;
2237 for (i = 0; i < schemeName.Length; i++)
2238 {
2239 if (schemeName[i] != ptr[scheme + i])
2240 {
2241 flags |= Flags.SchemeNotCanonical;
2242 }
2243 }
2244 if ((_flags & Flags.AuthorityFound) != Flags.Zero && (scheme + i + 3 >= length || ptr[scheme + i + 1] != '/' || ptr[scheme + i + 2] != '/'))
2245 {
2246 flags |= Flags.SchemeNotCanonical;
2247 }
2248 }
2249 if ((_flags & Flags.HasUserInfo) != Flags.Zero)
2250 {
2252 check = CheckCanonical(ptr, ref scheme, _info.Offset.Host, '@');
2253 if ((check & Check.DisplayCanonical) == 0)
2254 {
2255 flags |= Flags.UserNotCanonical;
2256 }
2257 if ((check & (Check.EscapedCanonical | Check.BackslashInPath)) != Check.EscapedCanonical)
2258 {
2259 flags |= Flags.E_UserNotCanonical;
2260 }
2261 if (IriParsing && (check & (Check.EscapedCanonical | Check.DisplayCanonical | Check.BackslashInPath | Check.NotIriCanonical | Check.FoundNonAscii)) == (Check.DisplayCanonical | Check.FoundNonAscii))
2262 {
2263 flags |= Flags.UserIriCanonical;
2264 }
2265 }
2266 }
2268 int num = _info.Offset.Path;
2269 if (flag)
2270 {
2271 if (IsFile && !IsUncPath)
2272 {
2273 if (IsImplicitFile)
2274 {
2275 _string = string.Empty;
2276 }
2277 else
2278 {
2280 }
2281 }
2282 _info.Offset.Path = (ushort)_string.Length;
2284 }
2286 {
2287 if (flag)
2288 {
2289 _string += _originalUnicodeString.Substring(num);
2290 }
2291 string @string = _string;
2292 if (IsImplicitFile || (flags2 & UriSyntaxFlags.MayHaveQuery) == 0)
2293 {
2294 scheme = @string.Length;
2295 }
2296 else
2297 {
2298 scheme = @string.IndexOf('?');
2299 if (scheme == -1)
2300 {
2301 scheme = @string.Length;
2302 }
2303 }
2304 _info.Offset.Query = (ushort)scheme;
2305 _info.Offset.Fragment = (ushort)@string.Length;
2306 _info.Offset.End = (ushort)@string.Length;
2307 }
2308 else
2309 {
2310 if (flag)
2311 {
2312 int start = num;
2313 if (IsImplicitFile || (flags2 & (UriSyntaxFlags.MayHaveQuery | UriSyntaxFlags.MayHaveFragment)) == 0)
2314 {
2315 num = _originalUnicodeString.Length;
2316 }
2317 else
2318 {
2320 int num2 = ((!_syntax.InFact(UriSyntaxFlags.MayHaveQuery)) ? span.IndexOf('#') : ((!_syntax.InFact(UriSyntaxFlags.MayHaveFragment)) ? span.IndexOf('?') : span.IndexOfAny('?', '#')));
2321 num = ((num2 == -1) ? _originalUnicodeString.Length : (num2 + num));
2322 }
2324 if (_string.Length > 65535)
2325 {
2326 UriFormatException exception = GetException(ParsingError.SizeLimit);
2327 throw exception;
2328 }
2329 length = _string.Length;
2331 {
2333 }
2334 }
2335 fixed (char* ptr2 = _string)
2336 {
2337 check = ((!IsImplicitFile && (flags2 & (UriSyntaxFlags.MayHaveQuery | UriSyntaxFlags.MayHaveFragment)) != 0) ? CheckCanonical(ptr2, ref scheme, length, ((flags2 & UriSyntaxFlags.MayHaveQuery) != 0) ? '?' : (_syntax.InFact(UriSyntaxFlags.MayHaveFragment) ? '#' : '\ufffe')) : CheckCanonical(ptr2, ref scheme, length, '\uffff'));
2338 if ((_flags & Flags.AuthorityFound) != Flags.Zero && (flags2 & UriSyntaxFlags.PathIsRooted) != 0 && (_info.Offset.Path == length || (ptr2[(int)_info.Offset.Path] != '/' && ptr2[(int)_info.Offset.Path] != '\\')))
2339 {
2340 flags |= Flags.FirstSlashAbsent;
2341 }
2342 }
2343 bool flag2 = false;
2344 if (IsDosPath || ((_flags & Flags.AuthorityFound) != Flags.Zero && ((flags2 & (UriSyntaxFlags.ConvertPathSlashes | UriSyntaxFlags.CompressPath)) != 0 || _syntax.InFact(UriSyntaxFlags.UnEscapeDotsAndSlashes))))
2345 {
2346 if ((check & Check.DotSlashEscaped) != 0 && _syntax.InFact(UriSyntaxFlags.UnEscapeDotsAndSlashes))
2347 {
2348 flags |= Flags.PathNotCanonical | Flags.E_PathNotCanonical;
2349 flag2 = true;
2350 }
2351 if ((flags2 & UriSyntaxFlags.ConvertPathSlashes) != 0 && (check & Check.BackslashInPath) != 0)
2352 {
2353 flags |= Flags.PathNotCanonical | Flags.E_PathNotCanonical;
2354 flag2 = true;
2355 }
2356 if ((flags2 & UriSyntaxFlags.CompressPath) != 0 && ((flags & Flags.E_PathNotCanonical) != Flags.Zero || (check & Check.DotSlashAttn) != 0))
2357 {
2358 flags |= Flags.ShouldBeCompressed;
2359 }
2360 if ((check & Check.BackslashInPath) != 0)
2361 {
2362 flags |= Flags.BackslashInPath;
2363 }
2364 }
2365 else if ((check & Check.BackslashInPath) != 0)
2366 {
2367 flags |= Flags.E_PathNotCanonical;
2368 flag2 = true;
2369 }
2370 if ((check & Check.DisplayCanonical) == 0 && ((_flags & Flags.ImplicitFile) == Flags.Zero || (_flags & Flags.UserEscaped) != Flags.Zero || (check & Check.ReservedFound) != 0))
2371 {
2372 flags |= Flags.PathNotCanonical;
2373 flag2 = true;
2374 }
2375 if ((_flags & Flags.ImplicitFile) != Flags.Zero && (check & (Check.EscapedCanonical | Check.ReservedFound)) != 0)
2376 {
2377 check &= ~Check.EscapedCanonical;
2378 }
2379 if ((check & Check.EscapedCanonical) == 0)
2380 {
2381 flags |= Flags.E_PathNotCanonical;
2382 }
2383 if (IriParsing && !flag2 && (check & (Check.EscapedCanonical | Check.DisplayCanonical | Check.NotIriCanonical | Check.FoundNonAscii)) == (Check.DisplayCanonical | Check.FoundNonAscii))
2384 {
2385 flags |= Flags.PathIriCanonical;
2386 }
2387 if (flag)
2388 {
2389 int start2 = num;
2390 if (num < _originalUnicodeString.Length && _originalUnicodeString[num] == '?')
2391 {
2392 if ((flags2 & UriSyntaxFlags.MayHaveFragment) != 0)
2393 {
2394 num++;
2395 int num3 = _originalUnicodeString.AsSpan(num).IndexOf('#');
2396 num = ((num3 == -1) ? _originalUnicodeString.Length : (num3 + num));
2397 }
2398 else
2399 {
2400 num = _originalUnicodeString.Length;
2401 }
2403 if (_string.Length > 65535)
2404 {
2405 UriFormatException exception2 = GetException(ParsingError.SizeLimit);
2406 throw exception2;
2407 }
2408 length = _string.Length;
2410 {
2412 }
2413 }
2414 }
2415 _info.Offset.Query = (ushort)scheme;
2416 fixed (char* ptr3 = _string)
2417 {
2418 if (scheme < length && ptr3[scheme] == '?')
2419 {
2420 scheme++;
2421 check = CheckCanonical(ptr3, ref scheme, length, ((flags2 & UriSyntaxFlags.MayHaveFragment) != 0) ? '#' : '\ufffe');
2422 if ((check & Check.DisplayCanonical) == 0)
2423 {
2424 flags |= Flags.QueryNotCanonical;
2425 }
2426 if ((check & (Check.EscapedCanonical | Check.BackslashInPath)) != Check.EscapedCanonical)
2427 {
2428 flags |= Flags.E_QueryNotCanonical;
2429 }
2430 if (IriParsing && (check & (Check.EscapedCanonical | Check.DisplayCanonical | Check.BackslashInPath | Check.NotIriCanonical | Check.FoundNonAscii)) == (Check.DisplayCanonical | Check.FoundNonAscii))
2431 {
2432 flags |= Flags.QueryIriCanonical;
2433 }
2434 }
2435 }
2436 if (flag)
2437 {
2438 int start3 = num;
2439 if (num < _originalUnicodeString.Length && _originalUnicodeString[num] == '#')
2440 {
2441 num = _originalUnicodeString.Length;
2443 if (_string.Length > 65535)
2444 {
2445 UriFormatException exception3 = GetException(ParsingError.SizeLimit);
2446 throw exception3;
2447 }
2448 length = _string.Length;
2450 }
2451 }
2452 _info.Offset.Fragment = (ushort)scheme;
2453 fixed (char* ptr4 = _string)
2454 {
2455 if (scheme < length && ptr4[scheme] == '#')
2456 {
2457 scheme++;
2458 check = CheckCanonical(ptr4, ref scheme, length, '\ufffe');
2459 if ((check & Check.DisplayCanonical) == 0)
2460 {
2461 flags |= Flags.FragmentNotCanonical;
2462 }
2463 if ((check & (Check.EscapedCanonical | Check.BackslashInPath)) != Check.EscapedCanonical)
2464 {
2465 flags |= Flags.E_FragmentNotCanonical;
2466 }
2467 if (IriParsing && (check & (Check.EscapedCanonical | Check.DisplayCanonical | Check.BackslashInPath | Check.NotIriCanonical | Check.FoundNonAscii)) == (Check.DisplayCanonical | Check.FoundNonAscii))
2468 {
2469 flags |= Flags.FragmentIriCanonical;
2470 }
2471 }
2472 }
2473 _info.Offset.End = (ushort)scheme;
2474 }
2475 }
2476 flags |= Flags.AllUriInfoSet | Flags.RestUnicodeNormalized;
2477 InterlockedSetFlags(flags);
2478 }
UriSyntaxFlags Flags
Definition UriParser.cs:85
string SchemeName
Definition UriParser.cs:81
bool InFact(UriSyntaxFlags flags)
Definition UriParser.cs:221
Offset Offset
Definition Uri.cs:81
UriParser _syntax
Definition Uri.cs:193
bool IriParsing
Definition Uri.cs:215
unsafe string EscapeUnescapeIri(string input, int start, int end, UriComponents component)
Definition Uri.cs:4092
void InterlockedSetFlags(Flags flags)
Definition Uri.cs:588
bool IsUncPath
Definition Uri.cs:207
bool IsFile
Definition Uri.cs:353
bool UserDrivenParsing
Definition Uri.cs:219
string _originalUnicodeString
Definition Uri.cs:191
bool DisablePathAndQueryCanonicalization
Definition Uri.cs:217
Flags _flags
Definition Uri.cs:195
bool IsDosPath
Definition Uri.cs:205
UriInfo EnsureUriInfo()
Definition Uri.cs:626
static readonly string SchemeDelimiter
Definition Uri.cs:187
bool InFact(Flags flags)
Definition Uri.cs:611
static UriFormatException GetException(ParsingError err)
Definition Uri.cs:873
string _string
Definition Uri.cs:189
unsafe Check CheckCanonical(char *str, ref int idx, int end, char delim)
Definition Uri.cs:2971
void GetLengthWithoutTrailingSpaces(string str, ref int length, int idx)
Definition Uri.cs:2205
UriInfo _info
Definition Uri.cs:197
bool IsImplicitFile
Definition Uri.cs:201
ushort Path
Definition Uri.cs:119
ushort User
Definition Uri.cs:113
ushort Host
Definition Uri.cs:115
ushort Scheme
Definition Uri.cs:111

References System.Uri._flags, System.Uri._info, System.Uri._originalUnicodeString, System.Uri._string, System.Uri._syntax, System.Uri.CheckCanonical(), System.Runtime.Serialization.Dictionary, System.Uri.DisablePathAndQueryCanonicalization, System.Uri.EnsureUriInfo(), System.Uri.EscapeUnescapeIri(), System.exception, System.UriParser.Flags, System.Uri.GetException(), System.Uri.GetLengthWithoutTrailingSpaces(), System.Uri.Offset.Host, System.UriParser.InFact(), System.Uri.InterlockedSetFlags(), System.Uri.IriParsing, System.Uri.IsDosPath, System.Uri.IsFile, System.Uri.IsImplicitFile, System.Uri.IsUncPath, System.length, System.Uri.UriInfo.Offset, System.Uri.Offset.Path, System.Uri.Offset.Scheme, System.Uri.SchemeDelimiter, System.UriParser.SchemeName, System.start, System.Uri.Offset.User, and System.Uri.UserDrivenParsing.

Referenced by System.Uri.EnsureParseRemaining().