Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
MailAddressParser.cs
Go to the documentation of this file.
4using System.Text;
5
6namespace System.Net.Mail;
7
8internal static class MailAddressParser
9{
11 {
12 int index = data.Length - 1;
14 }
15
16 internal static List<MailAddress> ParseMultipleAddresses(string data)
17 {
19 for (int index = data.Length - 1; index >= 0; index--)
20 {
22 list.Insert(0, new MailAddress(parseAddressInfo.DisplayName, parseAddressInfo.User, parseAddressInfo.Host, null));
23 }
24 return list;
25 }
26
28 {
30 {
32 return false;
33 }
34 bool flag = false;
35 if (data[index] == '>')
36 {
37 flag = true;
38 index--;
39 }
41 {
43 return false;
44 }
45 if (data[index] != '@')
46 {
48 {
50 }
52 return false;
53 }
54 index--;
56 {
58 return false;
59 }
60 if (flag)
61 {
62 if (index < 0 || data[index] != '<')
63 {
65 {
67 }
69 return false;
70 }
71 index--;
73 {
75 return false;
76 }
77 }
78 string displayName;
79 if (index >= 0 && (!expectMultipleAddresses || data[index] != ','))
80 {
82 {
84 return false;
85 }
86 }
87 else
88 {
89 displayName = string.Empty;
90 }
92 return true;
93 }
94
95 private static bool TryReadCfwsAndThrowIfIncomplete(string data, int index, out int outIndex, bool throwExceptionIfFail)
96 {
98 {
99 outIndex = 0;
100 return false;
101 }
102 if (index < 0)
103 {
105 {
107 }
108 outIndex = 0;
109 return false;
110 }
111 outIndex = index;
112 return true;
113 }
114
115 private static bool TryParseDomain(string data, ref int index, [NotNullWhen(true)] out string domain, bool throwExceptionIfFail)
116 {
118 {
119 domain = null;
120 return false;
121 }
122 int num = index;
123 if (data[index] == ']')
124 {
126 {
127 domain = null;
128 return false;
129 }
130 }
132 {
133 domain = null;
134 return false;
135 }
136 domain = data.Substring(index + 1, num - index);
138 {
139 return false;
140 }
142 {
143 return false;
144 }
145 return true;
146 }
147
148 private static bool TryParseLocalPart(string data, ref int index, bool expectAngleBracket, bool expectMultipleAddresses, [NotNullWhen(true)] out string localPart, bool throwExceptionIfFail)
149 {
151 {
152 localPart = null;
153 return false;
154 }
155 int num = index;
156 if (data[index] == '"')
157 {
159 {
160 localPart = null;
161 return false;
162 }
163 }
164 else
165 {
167 {
168 localPart = null;
169 return false;
170 }
171 if (index >= 0 && !MailBnfHelper.IsAllowedWhiteSpace(data[index]) && data[index] != ')' && (!expectAngleBracket || data[index] != '<') && (!expectMultipleAddresses || data[index] != ',') && data[index] != '"')
172 {
174 {
176 }
177 localPart = null;
178 return false;
179 }
180 }
181 localPart = data.Substring(index + 1, num - index);
183 {
184 return false;
185 }
187 {
188 return false;
189 }
190 return true;
191 }
192
193 private static bool TryParseDisplayName(string data, ref int index, bool expectMultipleAddresses, [NotNullWhen(true)] out string displayName, bool throwExceptionIfFail)
194 {
196 {
197 displayName = null;
198 return false;
199 }
200 if (outIndex >= 0 && data[outIndex] == '"')
201 {
203 {
204 displayName = null;
205 return false;
206 }
207 int num = index + 2;
208 displayName = data.Substring(num, outIndex - num);
210 {
211 return false;
212 }
213 if (index >= 0 && (!expectMultipleAddresses || data[index] != ','))
214 {
216 {
218 }
219 return false;
220 }
221 }
222 else
223 {
224 int num2 = index;
226 {
227 displayName = null;
228 return false;
229 }
230 displayName = data.SubstringTrim(index + 1, num2 - index);
231 }
233 {
234 return false;
235 }
236 return true;
237 }
238
239 internal static bool TryNormalizeOrThrow(string input, [NotNullWhen(true)] out string normalizedString, bool throwExceptionIfFail)
240 {
241 try
242 {
243 normalizedString = input.Normalize(NormalizationForm.FormC);
244 return true;
245 }
247 {
249 {
251 }
252 normalizedString = null;
253 return false;
254 }
255 }
256}
static bool TryReadReverse(string data, int index, out int outIndex, bool throwExceptionIfFail)
static bool TryReadReverse(string data, int index, out int outIndex, bool throwExceptionIfFail)
static bool TryParseAddress(string data, out ParseAddressInfo parsedAddress, bool throwExceptionIfFail)
static bool TryParseDisplayName(string data, ref int index, bool expectMultipleAddresses, [NotNullWhen(true)] out string displayName, bool throwExceptionIfFail)
static bool TryParseDomain(string data, ref int index, [NotNullWhen(true)] out string domain, bool throwExceptionIfFail)
static bool TryParseAddress(string data, bool expectMultipleAddresses, ref int index, out ParseAddressInfo parseAddressInfo, bool throwExceptionIfFail)
static bool TryReadCfwsAndThrowIfIncomplete(string data, int index, out int outIndex, bool throwExceptionIfFail)
static bool TryParseLocalPart(string data, ref int index, bool expectAngleBracket, bool expectMultipleAddresses, [NotNullWhen(true)] out string localPart, bool throwExceptionIfFail)
static bool TryNormalizeOrThrow(string input, [NotNullWhen(true)] out string normalizedString, bool throwExceptionIfFail)
static List< MailAddress > ParseMultipleAddresses(string data)
static bool TryReadReverseQuoted(string data, int index, bool permitUnicode, out int outIndex, bool throwExceptionIfFail)
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 bool TryReadCfwsReverse(string data, int index, out int outIndex, bool throwExceptionIfFail)
static bool IsAllowedWhiteSpace(char c)
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