Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Side by Side Diff: content/renderer/android/email_detector.cc

Issue 1541093002: Email Regular Expression update for exclusion of invalid domain parts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Patch Set 2 Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/renderer/android/email_detector_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/android/email_detector.h" 5 #include "content/renderer/android/email_detector.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "content/public/renderer/android_content_detection_prefixes.h" 10 #include "content/public/renderer/android_content_detection_prefixes.h"
11 #include "net/base/escape.h" 11 #include "net/base/escape.h"
12 #include "third_party/icu/source/i18n/unicode/regex.h" 12 #include "third_party/icu/source/i18n/unicode/regex.h"
13 13
14 namespace { 14 namespace {
15 15
16 // Maximum length of an email address. 16 // Maximum length of an email address.
17 const size_t kMaximumEmailLength = 254; 17 const size_t kMaximumEmailLength = 254;
18 18
19 // Regex to match email addresses. 19 // Regex to match email addresses.
20 // This is more specific than RFC 2822 (uncommon special characters are 20 // This is more specific than RFC 2822 (uncommon special characters are
21 // disallowed) in order to avoid false positives. 21 // disallowed) in order to avoid false positives.
22 // Delimiters are word boundaries to allow punctuation, quote marks etc. around 22 // Delimiters are word boundaries to allow punctuation, quote marks etc. around
23 // the address. 23 // the address.
24 const char kEmailRegex[] = "\\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,6}\\b"; 24 const char kEmailRegex[] =
25 "\\b[A-Z0-9._%+-]+@[A-Z0-9-]+(\\.[A-Z0-9-]+)*(\\.[A-Z]{2,6})\\b";
25 26
26 } // anonymous namespace 27 } // anonymous namespace
27 28
28 namespace content { 29 namespace content {
29 30
30 EmailDetector::EmailDetector() { 31 EmailDetector::EmailDetector() {
31 } 32 }
32 33
33 size_t EmailDetector::GetMaximumContentLength() { 34 size_t EmailDetector::GetMaximumContentLength() {
34 return kMaximumEmailLength; 35 return kMaximumEmailLength;
(...skipping 30 matching lines...) Expand all
65 DCHECK(U_SUCCESS(status)); 66 DCHECK(U_SUCCESS(status));
66 base::UTF16ToUTF8(content_ustr.getBuffer(), content_ustr.length(), 67 base::UTF16ToUTF8(content_ustr.getBuffer(), content_ustr.length(),
67 content_text); 68 content_text);
68 return true; 69 return true;
69 } 70 }
70 71
71 return false; 72 return false;
72 } 73 }
73 74
74 } // namespace content 75 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/android/email_detector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698