Changeset 49508 in webkit
- Timestamp:
- Oct 13, 2009 1:53:12 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r49507 r49508 1 2009-10-13 Michelangelo De Simone <micdesim@gmail.com> 2 3 Reviewed by Adam Barth. 4 5 https://bugs.webkit.org/show_bug.cgi?id=27457 6 Test case for static email validation on type=email input elements as 7 per HTML5 specs: 8 http://www.whatwg.org/specs/web-apps/current-work/#e-mail-state 9 10 * fast/forms/ValidityState-typeMismatch-email-expected.txt: Added. 11 * fast/forms/ValidityState-typeMismatch-email.html: Added. 12 * fast/forms/resources/ValidityState-typeMismatch-email.js: Added. 13 (): 14 1 15 2009-10-13 Dmitry Titov <dimich@chromium.org> 2 16 -
trunk/WebCore/ChangeLog
r49507 r49508 1 2009-10-13 Michelangelo De Simone <micdesim@gmail.com> 2 3 Reviewed by Adam Barth. 4 5 https://bugs.webkit.org/show_bug.cgi?id=27457 6 Added support for static validation on type=email input elements as per 7 HTML5 specs: 8 http://www.whatwg.org/specs/web-apps/current-work/#e-mail-state 9 10 Test: fast/forms/ValidityState-typeMismatch-email.html 11 12 * html/ValidityState.cpp: 13 (WebCore::ValidityState::typeMismatch): ValidityState.typeMismatch 14 performs validation on type=email input elements now. 15 (WebCore::ValidityState::isValidEmailAddress): simple validation method 16 * html/ValidityState.h: 17 1 18 2009-10-13 Dmitry Titov <dimich@chromium.org> 2 19 -
trunk/WebCore/html/ValidityState.cpp
r49199 r49508 27 27 #include "HTMLNames.h" 28 28 #include "KURL.h" 29 #include "RegularExpression.h" 30 #include <wtf/StdLibExtras.h> 31 32 #define EMAIL_LOCALPART "[a-z0-9!#$%&'*+/=?^_`{|}~.-]+" 33 #define EMAIL_DOMAINPART "[a-z0-9-]+(\\.[a-z0-9-]+)+" 34 #define EMAIL_PATTERN EMAIL_LOCALPART "@" EMAIL_DOMAINPART 29 35 30 36 namespace WebCore { … … 56 62 case HTMLInputElement::URL: 57 63 return !KURL(KURL(), value).isValid(); 64 case HTMLInputElement::EMAIL: 65 { 66 if (!input->multiple()) 67 return !isValidEmailAddress(value); 68 69 Vector<String> email_list; 70 value.split(',', email_list); 71 for (unsigned i = 0; i < email_list.size(); ++i) 72 if (!isValidEmailAddress(email_list[i])) 73 return true; 74 75 return false; 76 } 58 77 default: 59 78 return false; … … 96 115 } 97 116 117 bool ValidityState::isValidEmailAddress(const String& email) 118 { 119 if (email.isEmpty()) 120 return false; 121 122 DEFINE_STATIC_LOCAL(AtomicString, emailPattern, (EMAIL_PATTERN)); 123 DEFINE_STATIC_LOCAL(RegularExpression, regExp, (emailPattern, TextCaseInsensitive)); 124 125 int matchLength = 0; 126 int emailLength = email.length(); 127 int matchOffset = regExp.match(email, 0, &matchLength); 128 129 return matchOffset == 0 && matchLength == emailLength; 130 } 131 98 132 } // namespace -
trunk/WebCore/html/ValidityState.h
r49199 r49508 57 57 58 58 static bool isValidColorString(const String&); 59 bool isValidEmailAddress(const String&); 59 60 }; 60 61
Note: See TracChangeset
for help on using the changeset viewer.