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

◆ CheckSchemeSyntax()

static unsafe ParsingError System.Uri.CheckSchemeSyntax ( ReadOnlySpan< char > span,
ref UriParser syntax )
inlinestaticprivate

Definition at line 2553 of file Uri.cs.

2554 {
2555 if (span.Length == 0)
2556 {
2557 return ParsingError.BadScheme;
2558 }
2559 char c2 = span[0];
2560 switch (c2)
2561 {
2562 case 'A':
2563 case 'B':
2564 case 'C':
2565 case 'D':
2566 case 'E':
2567 case 'F':
2568 case 'G':
2569 case 'H':
2570 case 'I':
2571 case 'J':
2572 case 'K':
2573 case 'L':
2574 case 'M':
2575 case 'N':
2576 case 'O':
2577 case 'P':
2578 case 'Q':
2579 case 'R':
2580 case 'S':
2581 case 'T':
2582 case 'U':
2583 case 'V':
2584 case 'W':
2585 case 'X':
2586 case 'Y':
2587 case 'Z':
2588 c2 = (char)(c2 | 0x20u);
2589 break;
2590 default:
2591 return ParsingError.BadScheme;
2592 case 'a':
2593 case 'b':
2594 case 'c':
2595 case 'd':
2596 case 'e':
2597 case 'f':
2598 case 'g':
2599 case 'h':
2600 case 'i':
2601 case 'j':
2602 case 'k':
2603 case 'l':
2604 case 'm':
2605 case 'n':
2606 case 'o':
2607 case 'p':
2608 case 'q':
2609 case 'r':
2610 case 's':
2611 case 't':
2612 case 'u':
2613 case 'v':
2614 case 'w':
2615 case 'x':
2616 case 'y':
2617 case 'z':
2618 break;
2619 }
2620 switch (span.Length)
2621 {
2622 case 2:
2623 if (30579 == (((uint)c2 << 8) | ToLowerCaseAscii(span[1])))
2624 {
2625 syntax = UriParser.WsUri;
2626 return ParsingError.None;
2627 }
2628 break;
2629 case 3:
2630 switch ((int)(((uint)c2 << 16) | ((uint)ToLowerCaseAscii(span[1]) << 8) | ToLowerCaseAscii(span[2])))
2631 {
2632 case 6714480:
2633 syntax = UriParser.FtpUri;
2634 return ParsingError.None;
2635 case 7828339:
2636 syntax = UriParser.WssUri;
2637 return ParsingError.None;
2638 }
2639 break;
2640 case 4:
2641 switch ((int)(((uint)c2 << 24) | ((uint)ToLowerCaseAscii(span[1]) << 16) | ((uint)ToLowerCaseAscii(span[2]) << 8) | ToLowerCaseAscii(span[3])))
2642 {
2643 case 1752462448:
2644 syntax = UriParser.HttpUri;
2645 return ParsingError.None;
2646 case 1718185061:
2647 syntax = UriParser.FileUri;
2648 return ParsingError.None;
2649 }
2650 break;
2651 case 5:
2652 if (1752462448 == (((uint)c2 << 24) | ((uint)ToLowerCaseAscii(span[1]) << 16) | ((uint)ToLowerCaseAscii(span[2]) << 8) | ToLowerCaseAscii(span[3])) && ToLowerCaseAscii(span[4]) == 's')
2653 {
2654 syntax = UriParser.HttpsUri;
2655 return ParsingError.None;
2656 }
2657 break;
2658 case 6:
2659 if (1835100524 == (((uint)c2 << 24) | ((uint)ToLowerCaseAscii(span[1]) << 16) | ((uint)ToLowerCaseAscii(span[2]) << 8) | ToLowerCaseAscii(span[3])) && ToLowerCaseAscii(span[4]) == 't' && ToLowerCaseAscii(span[5]) == 'o')
2660 {
2661 syntax = UriParser.MailToUri;
2662 return ParsingError.None;
2663 }
2664 break;
2665 }
2666 for (int i = 1; i < span.Length; i++)
2667 {
2668 char c3 = span[i];
2669 if ((uint)(c3 - 97) > 25u && (uint)(c3 - 65) > 25u && (uint)(c3 - 48) > 9u && c3 != '+' && c3 != '-' && c3 != '.')
2670 {
2671 return ParsingError.BadScheme;
2672 }
2673 }
2674 if (span.Length > 1024)
2675 {
2676 return ParsingError.SchemeLimit;
2677 }
2678 string lwrCaseScheme;
2679 fixed (char* ptr = span)
2680 {
2681 lwrCaseScheme = string.Create(span.Length, ((IntPtr)ptr, span.Length), delegate(Span<char> buffer, (IntPtr ip, int length) state)
2682 {
2683 int num = new ReadOnlySpan<char>((void*)state.ip, state.length).ToLowerInvariant(buffer);
2684 });
2685 }
2686 syntax = UriParser.FindOrFetchAsUnknownV1Syntax(lwrCaseScheme);
2687 return ParsingError.None;
2688 static char ToLowerCaseAscii(char c)
2689 {
2690 if ((uint)(c - 65) > 25u)
2691 {
2692 return c;
2693 }
2694 return (char)(c | 0x20u);
2695 }
2696 }

References System.buffer, System.Runtime.Serialization.Dictionary, System.UriParser.FileUri, System.UriParser.FindOrFetchAsUnknownV1Syntax(), System.UriParser.FtpUri, System.UriParser.HttpsUri, System.UriParser.HttpUri, System.length, System.UriParser.MailToUri, System.state, System.UriParser.WssUri, and System.UriParser.WsUri.

Referenced by System.Uri.GetCombinedString(), and System.Uri.ParseSchemeCheckImplicitFile().