Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
QuotedStringFormatReader.cs
Go to the documentation of this file.
2
3namespace System.Net.Mail;
4
5internal static class QuotedStringFormatReader
6{
7 internal static bool TryReadReverseQuoted(string data, int index, bool permitUnicode, out int outIndex, bool throwExceptionIfFail)
8 {
9 index--;
10 do
11 {
12 if (!WhitespaceReader.TryReadFwsReverse(data, index, out index, throwExceptionIfFail))
13 {
14 outIndex = 0;
15 return false;
16 }
17 if (index < 0)
18 {
19 break;
20 }
21 if (!QuotedPairReader.TryCountQuotedChars(data, index, permitUnicode, out var outIndex2, throwExceptionIfFail))
22 {
23 outIndex = 0;
24 return false;
25 }
26 if (outIndex2 > 0)
27 {
28 index -= outIndex2;
29 continue;
30 }
31 if (data[index] == '"')
32 {
33 outIndex = index - 1;
34 return true;
35 }
36 if (!IsValidQtext(permitUnicode, data[index]))
37 {
38 if (throwExceptionIfFail)
39 {
41 }
42 outIndex = 0;
43 return false;
44 }
45 index--;
46 }
47 while (index >= 0);
48 if (throwExceptionIfFail)
49 {
51 }
52 outIndex = 0;
53 return false;
54 }
55
56 internal static bool TryReadReverseUnQuoted(string data, int index, bool permitUnicode, bool expectCommaDelimiter, out int outIndex, bool throwExceptionIfFail)
57 {
58 do
59 {
60 if (!WhitespaceReader.TryReadFwsReverse(data, index, out index, throwExceptionIfFail))
61 {
62 outIndex = 0;
63 return false;
64 }
65 if (index < 0)
66 {
67 break;
68 }
69 if (!QuotedPairReader.TryCountQuotedChars(data, index, permitUnicode, out var outIndex2, throwExceptionIfFail))
70 {
71 outIndex = 0;
72 return false;
73 }
74 if (outIndex2 > 0)
75 {
76 index -= outIndex2;
77 continue;
78 }
79 if (expectCommaDelimiter && data[index] == ',')
80 {
81 break;
82 }
83 if (!IsValidQtext(permitUnicode, data[index]))
84 {
85 if (throwExceptionIfFail)
86 {
88 }
89 outIndex = 0;
90 return false;
91 }
92 index--;
93 }
94 while (index >= 0);
95 outIndex = index;
96 return true;
97 }
98
99 private static bool IsValidQtext(bool allowUnicode, char ch)
100 {
101 if (ch > '\u007f')
102 {
103 return allowUnicode;
104 }
105 return MailBnfHelper.Qtext[(uint)ch];
106 }
107}
static bool TryCountQuotedChars(string data, int index, bool permitUnicodeEscaping, out int outIndex, bool throwExceptionIfFail)
static bool TryReadReverseQuoted(string data, int index, bool permitUnicode, out int outIndex, bool throwExceptionIfFail)
static bool IsValidQtext(bool allowUnicode, char ch)
static bool TryReadReverseUnQuoted(string data, int index, bool permitUnicode, bool expectCommaDelimiter, out int outIndex, bool throwExceptionIfFail)
static bool TryReadFwsReverse(string data, int index, out int outIndex, bool throwExceptionIfFail)
static readonly bool[] Qtext
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string MailHeaderFieldInvalidCharacter
Definition SR.cs:140
Definition SR.cs:7