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

◆ TryReadCfwsReverse()

static bool System.Net.Mail.WhitespaceReader.TryReadCfwsReverse ( string data,
int index,
out int outIndex,
bool throwExceptionIfFail )
inlinestaticpackage

Definition at line 51 of file WhitespaceReader.cs.

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 {
82 throw new FormatException(System.SR.Format(System.SR.MailHeaderFieldInvalidCharacter, '('));
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 {
99 throw new FormatException(System.SR.Format(System.SR.MailHeaderFieldInvalidCharacter, data[index]));
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 {
116 throw new FormatException(System.SR.Format(System.SR.MailHeaderFieldInvalidCharacter, ')'));
117 }
118 outIndex = 0;
119 return false;
120 }
121 outIndex = index;
122 return true;
123 }
static bool TryReadFwsReverse(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
Definition SR.cs:7

References System.Net.Mime.MailBnfHelper.Ctext, System.SR.Format(), System.index, System.SR.MailHeaderFieldInvalidCharacter, System.Net.Mail.QuotedPairReader.TryCountQuotedChars(), and System.Net.Mail.WhitespaceReader.TryReadFwsReverse().

Referenced by System.Net.Mail.MailAddressParser.TryParseDisplayName(), System.Net.Mail.MailAddressParser.TryParseLocalPart(), and System.Net.Mail.MailAddressParser.TryReadCfwsAndThrowIfIncomplete().