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

◆ CheckCanonical()

unsafe Check System.Uri.CheckCanonical ( char * str,
ref int idx,
int end,
char delim )
inlineprivate

Definition at line 2971 of file Uri.cs.

2972 {
2973 Check check = Check.None;
2974 bool flag = false;
2975 bool flag2 = false;
2976 bool iriParsing = IriParsing;
2977 int i;
2978 for (i = idx; i < end; i++)
2979 {
2980 char c = str[i];
2981 if (c <= '\u001f' || (c >= '\u007f' && c <= '\u009f'))
2982 {
2983 flag = true;
2984 flag2 = true;
2985 check |= Check.ReservedFound;
2986 continue;
2987 }
2988 if (c > '~')
2989 {
2990 if (iriParsing)
2991 {
2992 bool flag3 = false;
2993 check |= Check.FoundNonAscii;
2994 if (char.IsHighSurrogate(c))
2995 {
2996 if (i + 1 < end)
2997 {
2998 flag3 = IriHelper.CheckIriUnicodeRange(c, str[i + 1], out var _, isQuery: true);
2999 }
3000 }
3001 else
3002 {
3003 flag3 = IriHelper.CheckIriUnicodeRange(c, isQuery: true);
3004 }
3005 if (!flag3)
3006 {
3007 check |= Check.NotIriCanonical;
3008 }
3009 }
3010 if (!flag)
3011 {
3012 flag = true;
3013 }
3014 continue;
3015 }
3016 if (c == delim || (delim == '?' && c == '#' && _syntax != null && _syntax.InFact(UriSyntaxFlags.MayHaveFragment)))
3017 {
3018 break;
3019 }
3020 if (c == '?')
3021 {
3022 if (IsImplicitFile || (_syntax != null && !_syntax.InFact(UriSyntaxFlags.MayHaveQuery) && delim != '\ufffe'))
3023 {
3024 check |= Check.ReservedFound;
3025 flag2 = true;
3026 flag = true;
3027 }
3028 continue;
3029 }
3030 if (c == '#')
3031 {
3032 flag = true;
3033 if (IsImplicitFile || (_syntax != null && !_syntax.InFact(UriSyntaxFlags.MayHaveFragment)))
3034 {
3035 check |= Check.ReservedFound;
3036 flag2 = true;
3037 }
3038 continue;
3039 }
3040 if (c == '/' || c == '\\')
3041 {
3042 if ((check & Check.BackslashInPath) == 0 && c == '\\')
3043 {
3044 check |= Check.BackslashInPath;
3045 }
3046 if ((check & Check.DotSlashAttn) == 0 && i + 1 != end && (str[i + 1] == '/' || str[i + 1] == '\\'))
3047 {
3048 check |= Check.DotSlashAttn;
3049 }
3050 continue;
3051 }
3052 if (c == '.')
3053 {
3054 if (((check & Check.DotSlashAttn) == 0 && i + 1 == end) || str[i + 1] == '.' || str[i + 1] == '/' || str[i + 1] == '\\' || str[i + 1] == '?' || str[i + 1] == '#')
3055 {
3056 check |= Check.DotSlashAttn;
3057 }
3058 continue;
3059 }
3060 if ((c > '"' || c == '!') && (c < '[' || c > '^'))
3061 {
3062 switch (c)
3063 {
3064 case '<':
3065 case '>':
3066 case '`':
3067 break;
3068 case '{':
3069 case '|':
3070 case '}':
3071 flag = true;
3072 continue;
3073 default:
3074 if (c != '%')
3075 {
3076 continue;
3077 }
3078 if (!flag2)
3079 {
3080 flag2 = true;
3081 }
3082 if (i + 2 < end && (c = UriHelper.DecodeHexChars(str[i + 1], str[i + 2])) != '\uffff')
3083 {
3084 if (c == '.' || c == '/' || c == '\\')
3085 {
3086 check |= Check.DotSlashEscaped;
3087 }
3088 i += 2;
3089 }
3090 else if (!flag)
3091 {
3092 flag = true;
3093 }
3094 continue;
3095 }
3096 }
3097 if (!flag)
3098 {
3099 flag = true;
3100 }
3101 if ((_flags & Flags.HasUnicode) != Flags.Zero)
3102 {
3103 check |= Check.NotIriCanonical;
3104 }
3105 }
3106 if (flag2)
3107 {
3108 if (!flag)
3109 {
3110 check |= Check.EscapedCanonical;
3111 }
3112 }
3113 else
3114 {
3115 check |= Check.DisplayCanonical;
3116 if (!flag)
3117 {
3118 check |= Check.EscapedCanonical;
3119 }
3120 }
3121 idx = i;
3122 return check;
3123 }
bool InFact(UriSyntaxFlags flags)
Definition UriParser.cs:221
UriParser _syntax
Definition Uri.cs:193
bool IriParsing
Definition Uri.cs:215
Flags _flags
Definition Uri.cs:195
bool IsImplicitFile
Definition Uri.cs:201

References System.Uri._flags, System.Uri._syntax, System.IriHelper.CheckIriUnicodeRange(), System.UriHelper.DecodeHexChars(), System.UriParser.InFact(), System.Uri.IriParsing, System.Uri.IsImplicitFile, and System.str.

Referenced by System.Uri.CreateHostString(), System.Uri.InternalIsWellFormedOriginalString(), and System.Uri.ParseRemaining().