Rev 14 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 14 | Rev 15 | ||
---|---|---|---|
Line 227... | Line 227... | ||
227 | // local-part = dot-atom / quoted-string / obs-local-part |
227 | // local-part = dot-atom / quoted-string / obs-local-part |
228 | // obs-local-part = word *("." word) |
228 | // obs-local-part = word *("." word) |
229 | // (http://tools.ietf.org/html/rfc5322#section-3.4.1) |
229 | // (http://tools.ietf.org/html/rfc5322#section-3.4.1) |
230 | // |
230 | // |
231 | // Problem: need to distinguish between "first.last" and "first"."last" |
231 | // Problem: need to distinguish between "first.last" and "first"."last" |
232 | // (i.e. one element or two). And I suck at regexes. |
232 | // (i.e. one element or two). And I suck at regular expressions. |
233 | 233 | ||
234 | String[] dotArray = PHPFunctions.preg_split( |
234 | String[] dotArray = PHPFunctions.preg_split( |
235 | "(?m)\\.(?=(?:[^\\\"]*\\\"[^\\\"]*\\\")*(?![^\\\"]*\\\"))", |
235 | "(?m)\\.(?=(?:[^\\\"]*\\\"[^\\\"]*\\\")*(?![^\\\"]*\\\"))", |
236 | localPart); |
236 | localPart); |
237 | int partLength = 0; |
237 | int partLength = 0; |
Line 246... | Line 246... | ||
246 | // Can't have empty element (consecutive dots or |
246 | // Can't have empty element (consecutive dots or |
247 | // dots at the start or end) |
247 | // dots at the start or end) |
248 | return EMailSyntaxDiagnosis.ISEMAIL_ZEROLENGTHELEMENT; |
248 | return EMailSyntaxDiagnosis.ISEMAIL_ZEROLENGTHELEMENT; |
249 | } |
249 | } |
250 | // revision 1.15: Speed up the test and get rid of |
250 | // revision 1.15: Speed up the test and get rid of |
251 | // "unitialized string offset" notices from PHP |
251 | // "uninitialized string offset" notices from PHP |
252 | 252 | ||
253 | // We need to remove any valid comments (i.e. those at the start or |
253 | // We need to remove any valid comments (i.e. those at the start or |
254 | // end of the element) |
254 | // end of the element) |
255 | if (element.charAt(0) == '(') { |
255 | if (element.charAt(0) == '(') { |
256 | int indexBrace = element.indexOf(')'); |
256 | int indexBrace = element.indexOf(')'); |
Line 297... | Line 297... | ||
297 | // Quoted-string tests: |
297 | // Quoted-string tests: |
298 | // |
298 | // |
299 | // Remove any FWS |
299 | // Remove any FWS |
300 | element = PHPFunctions.preg_replace("(?<!\\\\)" + FWS, "", |
300 | element = PHPFunctions.preg_replace("(?<!\\\\)" + FWS, "", |
301 | element); |
301 | element); |
302 | // My regex skillz aren't up to distinguishing between \" \\" |
302 | // My regular expression skills aren't up to distinguishing |
303 | // \\\" \\\\" etc. |
303 | // between \" \\" \\\" \\\\" etc. |
304 | // So remove all \\ from the string first... |
304 | // So remove all \\ from the string first... |
305 | element = PHPFunctions.preg_replace("\\\\\\\\", " ", element); |
305 | element = PHPFunctions.preg_replace("\\\\\\\\", " ", element); |
306 | if (PHPFunctions |
306 | if (PHPFunctions |
307 | .preg_match( |
307 | .preg_match( |
308 | "(?<!\\\\|^)[\"\\r\\n\\x00](?!$)|\\\\\"$|\"\"", |
308 | "(?<!\\\\|^)[\"\\r\\n\\x00](?!$)|\\\\\"$|\"\"", |
Line 516... | Line 516... | ||
516 | if (elementLength == 0) { |
516 | if (elementLength == 0) { |
517 | // Dots in wrong place |
517 | // Dots in wrong place |
518 | return EMailSyntaxDiagnosis.ISEMAIL_DOMAINEMPTYELEMENT; |
518 | return EMailSyntaxDiagnosis.ISEMAIL_DOMAINEMPTYELEMENT; |
519 | } |
519 | } |
520 | // revision 1.15: Speed up the test and get rid of |
520 | // revision 1.15: Speed up the test and get rid of |
521 | // "unitialized string offset" notices from PHP |
521 | // "uninitialized string offset" notices from PHP |
522 | 522 | ||
523 | // Then we need to remove all valid comments (i.e. those at the |
523 | // Then we need to remove all valid comments (i.e. those at the |
524 | // start or end of the element |
524 | // start or end of the element |
525 | if (element.charAt(0) == '(') { |
525 | if (element.charAt(0) == '(') { |
526 | int indexBrace = element.indexOf(')'); |
526 | int indexBrace = element.indexOf(')'); |