Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
HttpValidationHelpers.cs
Go to the documentation of this file.
1namespace System.Net;
2
3internal static class HttpValidationHelpers
4{
5 private static readonly char[] s_httpTrimCharacters = new char[6] { '\t', '\n', '\v', '\f', '\r', ' ' };
6
7 internal static string CheckBadHeaderNameChars(string name)
8 {
10 {
12 }
13 if (ContainsNonAsciiChars(name))
14 {
16 }
17 return name;
18 }
19
20 internal static bool ContainsNonAsciiChars(string token)
21 {
22 for (int i = 0; i < token.Length; i++)
23 {
24 if (token[i] < ' ' || token[i] > '~')
25 {
26 return true;
27 }
28 }
29 return false;
30 }
31
32 public static string CheckBadHeaderValueChars(string value)
33 {
34 if (string.IsNullOrEmpty(value))
35 {
36 return string.Empty;
37 }
39 int num = 0;
40 for (int i = 0; i < value.Length; i++)
41 {
42 char c = (char)(0xFFu & value[i]);
43 switch (num)
44 {
45 case 0:
46 if (c == '\r')
47 {
48 num = 1;
49 }
50 else if (c == '\n')
51 {
52 num = 2;
53 }
54 else if (c == '\u007f' || (c < ' ' && c != '\t'))
55 {
57 }
58 break;
59 case 1:
60 if (c == '\n')
61 {
62 num = 2;
63 break;
64 }
66 case 2:
67 if (c == ' ' || c == '\t')
68 {
69 num = 0;
70 break;
71 }
73 }
74 }
75 if (num != 0)
76 {
78 }
79 return value;
80 }
81
82 public static bool IsInvalidMethodOrHeaderString(string stringValue)
83 {
84 for (int i = 0; i < stringValue.Length; i++)
85 {
86 switch (stringValue[i])
87 {
88 case '\t':
89 case '\n':
90 case '\r':
91 case ' ':
92 case '"':
93 case '\'':
94 case '(':
95 case ')':
96 case ',':
97 case '/':
98 case ':':
99 case ';':
100 case '<':
101 case '=':
102 case '>':
103 case '?':
104 case '@':
105 case '[':
106 case '\\':
107 case ']':
108 case '{':
109 case '}':
110 return true;
111 }
112 }
113 return false;
114 }
115}
static string CheckBadHeaderNameChars(string name)
static readonly char[] s_httpTrimCharacters
static string CheckBadHeaderValueChars(string value)
static bool ContainsNonAsciiChars(string token)
static bool IsInvalidMethodOrHeaderString(string stringValue)
static string net_WebHeaderInvalidCRLFChars
Definition SR.cs:72
static string net_WebHeaderInvalidControlChars
Definition SR.cs:102
static string net_WebHeaderInvalidHeaderChars
Definition SR.cs:24
Definition SR.cs:7