Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
WhitespaceReader.cs
Go to the documentation of this file.
2
3namespace System.Net.Mail;
4
5internal static class WhitespaceReader
6{
7 internal static bool TryReadFwsReverse(string data, int index, out int outIndex, bool throwExceptionIfFail)
8 {
9 bool flag = false;
10 while (index >= 0)
11 {
12 if (data[index] == '\r' && flag)
13 {
14 flag = false;
15 }
16 else
17 {
18 if (data[index] == '\r' || flag)
19 {
20 if (throwExceptionIfFail)
21 {
23 }
24 outIndex = 0;
25 return false;
26 }
27 if (data[index] == '\n')
28 {
29 flag = true;
30 }
31 else if (data[index] != ' ' && data[index] != '\t')
32 {
33 break;
34 }
35 }
36 index--;
37 }
38 if (flag)
39 {
40 if (throwExceptionIfFail)
41 {
43 }
44 outIndex = 0;
45 return false;
46 }
47 outIndex = index;
48 return true;
49 }
50
51 internal static bool TryReadCfwsReverse(string data, int index, out int outIndex, bool throwExceptionIfFail)
52 {
53 int num = 0;
54 if (!TryReadFwsReverse(data, index, out index, throwExceptionIfFail))
55 {
56 outIndex = 0;
57 return false;
58 }
59 while (index >= 0)
60 {
61 if (!QuotedPairReader.TryCountQuotedChars(data, index, permitUnicodeEscaping: true, out var outIndex2, throwExceptionIfFail))
62 {
63 outIndex = 0;
64 return false;
65 }
66 if (num > 0 && outIndex2 > 0)
67 {
68 index -= outIndex2;
69 }
70 else if (data[index] == ')')
71 {
72 num++;
73 index--;
74 }
75 else if (data[index] == '(')
76 {
77 num--;
78 if (num < 0)
79 {
80 if (throwExceptionIfFail)
81 {
83 }
84 outIndex = 0;
85 return false;
86 }
87 index--;
88 }
89 else
90 {
91 if (num <= 0 || (data[index] <= '\u007f' && !MailBnfHelper.Ctext[(uint)data[index]]))
92 {
93 if (num <= 0)
94 {
95 break;
96 }
97 if (throwExceptionIfFail)
98 {
100 }
101 outIndex = 0;
102 return false;
103 }
104 index--;
105 }
106 if (!TryReadFwsReverse(data, index, out index, throwExceptionIfFail))
107 {
108 outIndex = 0;
109 return false;
110 }
111 }
112 if (num > 0)
113 {
114 if (throwExceptionIfFail)
115 {
117 }
118 outIndex = 0;
119 return false;
120 }
121 outIndex = index;
122 return true;
123 }
124}
static bool TryCountQuotedChars(string data, int index, bool permitUnicodeEscaping, out int outIndex, bool throwExceptionIfFail)
static bool TryReadFwsReverse(string data, int index, out int outIndex, bool throwExceptionIfFail)
static bool TryReadCfwsReverse(string data, int index, out int outIndex, bool throwExceptionIfFail)
static readonly bool[] Ctext
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string MailHeaderFieldInvalidCharacter
Definition SR.cs:140
static string MailAddressInvalidFormat
Definition SR.cs:148
Definition SR.cs:7