Title: [89915] trunk
Revision
89915
Author
[email protected]
Date
2011-06-28 02:46:08 -0700 (Tue, 28 Jun 2011)

Log Message

2011-06-28  Kentaro Hara  <[email protected]>

        Reviewed by Kent Tamura.

        Allow spaces between e-mail addresses in 'email' input type.
        https://bugs.webkit.org/show_bug.cgi?id=55987

        Allowed spaces between e-mail addresses in 'email' input type,
        e.g. ' [email protected] , [email protected] ' is a valid value. Implemented the
        value sanitization algorithm for an e-mail value.  Added more unit
        tests that check the e-mail value parser.

        * fast/forms/ValidityState-typeMismatch-email-expected.txt:
        * fast/forms/resources/ValidityState-typeMismatch-email.js:
2011-06-28  Kentaro Hara  <[email protected]>

        Reviewed by Kent Tamura.

        Allow spaces between e-mail addresses in 'email' input type.
        https://bugs.webkit.org/show_bug.cgi?id=55987

        Allowed spaces between e-mail addresses in 'email' input type,
        e.g. ' [email protected] , [email protected] ' is a valid value. Implemented the
        value sanitization algorithm for an e-mail value.  Added more unit
        tests that check the e-mail value parser.

        Test: fast/forms/ValidityState-typeMismatch-email.html

        * html/EmailInputType.cpp:
        (WebCore::EmailInputType::typeMismatchFor):
        (WebCore::EmailInputType::sanitizeValue):
        * html/EmailInputType.h:
        * html/parser/HTMLParserIdioms.cpp:
        (WebCore::stripHTMLLineBreaks):
        * html/parser/HTMLParserIdioms.h:
        (WebCore::isHTMLLineBreak):

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (89914 => 89915)


--- trunk/LayoutTests/ChangeLog	2011-06-28 09:44:49 UTC (rev 89914)
+++ trunk/LayoutTests/ChangeLog	2011-06-28 09:46:08 UTC (rev 89915)
@@ -1,3 +1,18 @@
+2011-06-28  Kentaro Hara  <[email protected]>
+
+        Reviewed by Kent Tamura.
+
+        Allow spaces between e-mail addresses in 'email' input type.
+        https://bugs.webkit.org/show_bug.cgi?id=55987
+
+        Allowed spaces between e-mail addresses in 'email' input type,
+        e.g. ' [email protected] , [email protected] ' is a valid value. Implemented the
+        value sanitization algorithm for an e-mail value.  Added more unit
+        tests that check the e-mail value parser.
+
+        * fast/forms/ValidityState-typeMismatch-email-expected.txt:
+        * fast/forms/resources/ValidityState-typeMismatch-email.js:
+
 2011-06-28  Csaba Osztrogonác  <[email protected]>
 
         Qt specific results committed in r89901, but some of them fail on Qt-WK2 and/or Qt-Mac platform

Modified: trunk/LayoutTests/fast/forms/ValidityState-typeMismatch-email-expected.txt (89914 => 89915)


--- trunk/LayoutTests/fast/forms/ValidityState-typeMismatch-email-expected.txt	2011-06-28 09:44:49 UTC (rev 89914)
+++ trunk/LayoutTests/fast/forms/ValidityState-typeMismatch-email-expected.txt	2011-06-28 09:46:08 UTC (rev 89915)
@@ -1,47 +1,182 @@
-This test aims to check for typeMismatch flag with type=email input fields.
+This test aims to check for typeMismatch flag and sanitization with type=email input fields.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS [email protected] is a correct valid email address 
-PASS [email protected] is a correct valid email address 
-PASS [email protected] is a correct valid email address 
-PASS [email protected] is a correct valid email address 
-PASS a/[email protected] is a correct valid email address 
-PASS {}@domain.com is a correct valid email address 
-PASS [email protected] is a correct valid email address 
-PASS m*'!%@something.sa is a correct valid email address 
-PASS tu!!7n7.ad##[email protected] is a correct valid email address 
-PASS %@com.com is a correct valid email address 
-PASS !#$%&'*+/=?^_`{|}[email protected] is a correct valid email address 
-PASS [email protected] is a correct valid email address 
-PASS [email protected] is a correct valid email address 
-PASS [email protected] is a correct valid email address 
-PASS [email protected] is a correct valid email address 
-PASS [email protected] is a correct valid email address 
-PASS somebody@example is a correct valid email address 
-PASS invalid:[email protected] is a correct invalid email address 
-PASS @somewhere.com is a correct invalid email address 
-PASS example.com is a correct invalid email address 
-PASS @@example.com is a correct invalid email address 
-PASS a [email protected] is a correct invalid email address 
-PASS [email protected] is a correct invalid email address 
-PASS a@c is a correct invalid email address 
-PASS [email protected]. is a correct invalid email address 
-PASS ""testlah""@example.com is a correct invalid email address 
-PASS "testblah"@example.com is a correct invalid email address 
-PASS [email protected]@ is a correct invalid email address 
-PASS someone@somewhere_com is a correct invalid email address 
-PASS someone@some:where.com is a correct invalid email address 
-PASS . is a correct invalid email address 
-PASS F/s/f/a@feo+re.com is a correct invalid email address 
-PASS some+long+email+address@some+host-weird-/looking.com is a correct invalid email address 
-PASS [email protected],[email protected],[email protected],a/[email protected],[email protected] is a correct valid email address list
-PASS tu!!7n7.ad##[email protected],F/s/f/[email protected],m*'@a.b is a correct valid email address list
-PASS ,,,,,,,,,,, is a correct valid email address list
-PASS [email protected],[email protected],a@b,a/b@c,[email protected] is a correct invalid email address list
-PASS some+long+email+address@some+host:weird-/looking.com,F/s/f/a@feo+re.com,,m*'@'!% is a correct invalid email address list
-PASS ,,,,,,,,, ,, is a correct invalid email address list
+Valid single addresses when 'multiple' attribute is not set.
+PASS "[email protected]" is a valid email address. 
+PASS "[email protected]" is a valid email address. 
+PASS "[email protected]" is a valid email address. 
+PASS "[email protected]" is a valid email address. 
+PASS "a/[email protected]" is a valid email address. 
+PASS "{}@domain.com" is a valid email address. 
+PASS "[email protected]" is a valid email address. 
+PASS "m*'!%@something.sa" is a valid email address. 
+PASS "tu!!7n7.ad##[email protected]" is a valid email address. 
+PASS "%@com.com" is a valid email address. 
+PASS "!#$%&'*+/=?^_`{|}[email protected]" is a valid email address. 
+PASS "[email protected]" is a valid email address. 
+PASS "[email protected]" is a valid email address. 
+PASS "[email protected]" is a valid email address. 
+PASS "[email protected]" is a valid email address. 
+PASS "[email protected]" is a valid email address. 
+PASS "somebody@example" is a valid email address. 
+PASS "
[email protected]
+" is a valid email address. It was sanitized to "[email protected]".
+PASS "
[email protected]
+" is a valid email address. It was sanitized to "[email protected]".
+PASS "a
[email protected]" is a valid email address. It was sanitized to "[email protected]".
+PASS "a
[email protected]" is a valid email address. It was sanitized to "[email protected]".
+PASS "" is a valid email address. 
+Invalid single addresses when 'multiple' attribute is not set.
+PASS "invalid:[email protected]" is a invalid email address. 
+PASS "@somewhere.com" is a invalid email address. 
+PASS "example.com" is a invalid email address. 
+PASS "@@example.com" is a invalid email address. 
+PASS "a [email protected]" is a invalid email address. 
+PASS "[email protected]" is a invalid email address. 
+PASS "a@c" is a invalid email address. 
+PASS "[email protected]." is a invalid email address. 
+PASS """testlah""@example.com" is a invalid email address. 
+PASS ""testblah"@example.com" is a invalid email address. 
+PASS "[email protected]@" is a invalid email address. 
+PASS "someone@somewhere_com" is a invalid email address. 
+PASS "someone@some:where.com" is a invalid email address. 
+PASS "." is a invalid email address. 
+PASS "F/s/f/a@feo+re.com" is a invalid email address. 
+PASS "some+long+email+address@some+host-weird-/looking.com" is a invalid email address. 
+PASS " " is a invalid email address. 
+PASS " [email protected]" is a invalid email address. 
+PASS "[email protected] " is a invalid email address. 
+PASS " [email protected] " is a invalid email address. 
+PASS " [email protected] " is a invalid email address. 
+PASS "	[email protected]	" is a invalid email address. 
+PASS "[email protected]" is a invalid email address. 
+PASS "[email protected]" is a invalid email address. 
+PASS " [email protected] " is a invalid email address. 
+PASS " [email protected] " is a invalid email address. 
+PASS "a @p.com" is a invalid email address. 
+PASS "a @p.com" is a invalid email address. 
+PASS "a	@p.com" is a invalid email address. 
+PASS "a@p.com" is a invalid email address. 
+PASS "a@p.com" is a invalid email address. 
+PASS "a @p.com" is a invalid email address. 
+PASS "a @p.com" is a invalid email address. 
+Valid single addresses when 'multiple' attribute is set.
+PASS "[email protected]" is a valid email address list. 
+PASS "[email protected]" is a valid email address list. 
+PASS "[email protected]" is a valid email address list. 
+PASS "[email protected]" is a valid email address list. 
+PASS "a/[email protected]" is a valid email address list. 
+PASS "{}@domain.com" is a valid email address list. 
+PASS "[email protected]" is a valid email address list. 
+PASS "m*'!%@something.sa" is a valid email address list. 
+PASS "tu!!7n7.ad##[email protected]" is a valid email address list. 
+PASS "%@com.com" is a valid email address list. 
+PASS "!#$%&'*+/=?^_`{|}[email protected]" is a valid email address list. 
+PASS "[email protected]" is a valid email address list. 
+PASS "[email protected]" is a valid email address list. 
+PASS "[email protected]" is a valid email address list. 
+PASS "[email protected]" is a valid email address list. 
+PASS "[email protected]" is a valid email address list. 
+PASS "somebody@example" is a valid email address list. 
+PASS " [email protected] " is a valid email address list. It was sanitized to "[email protected]".
+PASS "	[email protected]	" is a valid email address list. It was sanitized to "[email protected]".
+PASS "
[email protected]
+" is a valid email address list. It was sanitized to "[email protected]".
+PASS "[email protected]" is a valid email address list. It was sanitized to "[email protected]".
+PASS "
[email protected]
+" is a valid email address list. It was sanitized to "[email protected]".
+PASS "a
[email protected]" is a valid email address list. It was sanitized to "[email protected]".
+PASS "a
[email protected]" is a valid email address list. It was sanitized to "[email protected]".
+PASS "" is a valid email address list. 
+PASS " " is a valid email address list. It was sanitized to "".
+PASS " [email protected]" is a valid email address list. It was sanitized to "[email protected]".
+PASS "[email protected] " is a valid email address list. It was sanitized to "[email protected]".
+PASS " [email protected] " is a valid email address list. It was sanitized to "[email protected]".
+Invalid single addresses when 'multiple' attribute is set.
+PASS "invalid:[email protected]" is a invalid email address list. 
+PASS "@somewhere.com" is a invalid email address list. 
+PASS "example.com" is a invalid email address list. 
+PASS "@@example.com" is a invalid email address list. 
+PASS "a [email protected]" is a invalid email address list. 
+PASS "[email protected]" is a invalid email address list. 
+PASS "a@c" is a invalid email address list. 
+PASS "[email protected]." is a invalid email address list. 
+PASS """testlah""@example.com" is a invalid email address list. 
+PASS ""testblah"@example.com" is a invalid email address list. 
+PASS "[email protected]@" is a invalid email address list. 
+PASS "someone@somewhere_com" is a invalid email address list. 
+PASS "someone@some:where.com" is a invalid email address list. 
+PASS "." is a invalid email address list. 
+PASS "F/s/f/a@feo+re.com" is a invalid email address list. 
+PASS "some+long+email+address@some+host-weird-/looking.com" is a invalid email address list. 
+PASS "[email protected]" is a invalid email address list. 
+PASS " [email protected] " is a invalid email address list. 
+PASS " [email protected] " is a invalid email address list. 
+PASS "a @p.com" is a invalid email address list. 
+PASS "a @p.com" is a invalid email address list. 
+PASS "a	@p.com" is a invalid email address list. 
+PASS "a@p.com" is a invalid email address list. 
+PASS "a@p.com" is a invalid email address list. 
+PASS "a @p.com" is a invalid email address list. 
+PASS "a @p.com" is a invalid email address list. 
+Valid multiple addresses when 'multiple' attribute is set.
+PASS "[email protected],[email protected],[email protected],a/[email protected],[email protected]" is a valid email address list. 
+PASS "tu!!7n7.ad##[email protected],F/s/f/[email protected],m*'@a.b" is a valid email address list. 
+PASS " [email protected],[email protected]" is a valid email address list. It was sanitized to "[email protected],[email protected]".
+PASS "[email protected] ,[email protected]" is a valid email address list. It was sanitized to "[email protected],[email protected]".
+PASS "[email protected], [email protected]" is a valid email address list. It was sanitized to "[email protected],[email protected]".
+PASS "[email protected],[email protected] " is a valid email address list. It was sanitized to "[email protected],[email protected]".
+PASS "   [email protected]   ,   [email protected]   " is a valid email address list. It was sanitized to "[email protected],[email protected]".
+PASS " [email protected] , [email protected] " is a valid email address list. It was sanitized to "[email protected],[email protected]".
+PASS "	[email protected]	,	[email protected]	" is a valid email address list. It was sanitized to "[email protected],[email protected]".
+PASS "
[email protected]
+,
[email protected]
+" is a valid email address list. It was sanitized to "[email protected],[email protected]".
+PASS "[email protected],[email protected]" is a valid email address list. It was sanitized to "[email protected],[email protected]".
+PASS "
[email protected]
+,
[email protected]
+" is a valid email address list. It was sanitized to "[email protected],[email protected]".
+Invalid multiple addresses when 'multiple' attribute is set.
+PASS "[email protected],[email protected],a@b,a/b@c,[email protected]" is a invalid email address list. 
+PASS "some+long+email+address@some+host:weird-/looking.com,F/s/f/a@feo+re.com,,m*'@'!%" is a invalid email address list. 
+PASS "   a @p.com   ,   [email protected]   " is a invalid email address list. It was sanitized to "a @p.com,[email protected]".
+PASS "   [email protected]   ,   b @p.com   " is a invalid email address list. It was sanitized to "[email protected],b @p.com".
+PASS "[email protected],[email protected]" is a invalid email address list. 
+PASS " [email protected] , [email protected] " is a invalid email address list. 
+PASS " [email protected] , [email protected] " is a invalid email address list. 
+PASS ",," is a invalid email address list. 
+PASS " ,," is a invalid email address list. It was sanitized to ",,".
+PASS ", ," is a invalid email address list. It was sanitized to ",,".
+PASS ",, " is a invalid email address list. It was sanitized to ",,".
+PASS "  ,  ,  " is a invalid email address list. It was sanitized to ",,".
+PASS " , , " is a invalid email address list. It was sanitized to ",,".
+PASS "	,	,	" is a invalid email address list. It was sanitized to ",,".
+PASS "
+,
+,
+" is a invalid email address list. It was sanitized to ",,".
+PASS ",," is a invalid email address list. 
+PASS ",," is a invalid email address list. It was sanitized to ",,".
+PASS "
+,
+,
+" is a invalid email address list. It was sanitized to ",,".
+PASS " , , " is a invalid email address list. 
+PASS " , , " is a invalid email address list. 
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/fast/forms/resources/ValidityState-typeMismatch-email.js (89914 => 89915)


--- trunk/LayoutTests/fast/forms/resources/ValidityState-typeMismatch-email.js	2011-06-28 09:44:49 UTC (rev 89914)
+++ trunk/LayoutTests/fast/forms/resources/ValidityState-typeMismatch-email.js	2011-06-28 09:46:08 UTC (rev 89915)
@@ -1,70 +1,184 @@
-description("This test aims to check for typeMismatch flag with type=email input fields.");
+description("This test aims to check for typeMismatch flag and sanitization with type=email input fields.");
 
 var i = document.createElement('input');
 i.type = 'email';
 
-function emailCheck(val, expectedValid)
+function emailCheck(value, expectedValue, expectedMismatch, multiple)
 {
-    i.value = val;
-    var vs = i.validity.typeMismatch;
-    var didPass = vs == expectedValid;
-    var didPassText = didPass ? "a correct" : "an incorrect";
-    var validityText = vs ? "invalid" : "valid";
-    var multipleText = i.multiple ? "list" : "";
-    var resultText = val + " is " + didPassText + " " + validityText + " email address " + multipleText;
-    if (didPass)
-        testPassed(resultText);
+    i.value = value;
+    i.multiple = !!multiple;
+    var mismatch = i.validity.typeMismatch;
+    var mismatchPass = mismatch == expectedMismatch;
+    var sanitizePass = i.value == expectedValue;
+    var mismatchResult = '"' + value + '" is a ' + (mismatch ? 'invalid' : 'valid') + ' email address' + (multiple ? ' list. ' : '. ');
+    var sanitizeResult = 'It was sanitized to "' + i.value + '"' + (sanitizePass ? '.' : ', but should be sanitized to "' + expectedValue + '"');
+    var result = mismatchResult;
+    if (value != expectedValue || !sanitizePass)
+        result += sanitizeResult;
+
+    if (mismatchPass && sanitizePass)
+        testPassed(result);
     else
-        testFailed(resultText);
+        testFailed(result);
 }
 
-// VALID
-emailCheck("[email protected]", false);
-emailCheck("[email protected]", false);
-emailCheck("[email protected]", false);
-emailCheck("[email protected]", false);
-emailCheck("a/[email protected]", false);
-emailCheck("{}@domain.com", false);
-emailCheck("[email protected]", false);
-emailCheck("m*'!%@something.sa", false);
-emailCheck("tu!!7n7.ad##[email protected]", false);
-emailCheck("%@com.com", false);
-emailCheck("!#$%&'*+/=?^_`{|}[email protected]", false);
-emailCheck("[email protected]", false);
-emailCheck("[email protected]", false);
-emailCheck("[email protected]", false);
-emailCheck("[email protected]", false);
-emailCheck("[email protected]", false);
-emailCheck("somebody@example", false);
+var expectValid = false;
+var expectInvalid = true;
+var multiple = true;
 
-// INVALID
-emailCheck("invalid:[email protected]", true);
-emailCheck("@somewhere.com", true);
-emailCheck("example.com", true);
-emailCheck("@@example.com", true);
-emailCheck("a [email protected]", true);
-emailCheck("[email protected]", true);
-emailCheck("a\b@c", true);
-emailCheck("[email protected].", true);
-emailCheck("\"\"test\blah\"\"@example.com", true);
-emailCheck("\"testblah\"@example.com", true);
-emailCheck("[email protected]@", true);
-emailCheck("someone@somewhere_com", true);
-emailCheck("someone@some:where.com", true);
-emailCheck(".", true);
-emailCheck("F/s/f/a@feo+re.com", true);
-emailCheck("some+long+email+address@some+host-weird-/looking.com", true);
+debug("Valid single addresses when 'multiple' attribute is not set.");
+emailCheck("[email protected]", "[email protected]", expectValid);
+emailCheck("[email protected]", "[email protected]", expectValid);
+emailCheck("[email protected]", "[email protected]", expectValid);
+emailCheck("[email protected]", "[email protected]", expectValid);
+emailCheck("a/[email protected]", "a/[email protected]", expectValid);
+emailCheck("{}@domain.com", "{}@domain.com", expectValid);
+emailCheck("[email protected]", "[email protected]", expectValid);
+emailCheck("m*'!%@something.sa", "m*'!%@something.sa", expectValid);
+emailCheck("tu!!7n7.ad##[email protected]", "tu!!7n7.ad##[email protected]", expectValid);
+emailCheck("%@com.com", "%@com.com", expectValid);
+emailCheck("!#$%&'*+/=?^_`{|}[email protected]", "!#$%&'*+/=?^_`{|}[email protected]", expectValid);
+emailCheck("[email protected]", "[email protected]", expectValid);
+emailCheck("[email protected]", "[email protected]", expectValid);
+emailCheck("[email protected]", "[email protected]", expectValid);
+emailCheck("[email protected]", "[email protected]", expectValid);
+emailCheck("[email protected]", "[email protected]", expectValid);
+emailCheck("somebody@example", "somebody@example", expectValid);
+emailCheck("\[email protected]\u000A", "[email protected]", expectValid);
+emailCheck("\[email protected]\u000D", "[email protected]", expectValid);
+emailCheck("a\[email protected]", "[email protected]", expectValid);
+emailCheck("a\[email protected]", "[email protected]", expectValid);
+emailCheck("", "", expectValid);
 
-i.multiple = true;
+debug("Invalid single addresses when 'multiple' attribute is not set.");
+emailCheck("invalid:[email protected]", "invalid:[email protected]", expectInvalid);
+emailCheck("@somewhere.com", "@somewhere.com", expectInvalid);
+emailCheck("example.com", "example.com", expectInvalid);
+emailCheck("@@example.com", "@@example.com", expectInvalid);
+emailCheck("a [email protected]", "a [email protected]", expectInvalid);
+emailCheck("[email protected]", "[email protected]", expectInvalid);
+emailCheck("a\b@c", "a\b@c", expectInvalid);
+emailCheck("[email protected].", "[email protected].", expectInvalid);
+emailCheck("\"\"test\blah\"\"@example.com", "\"\"test\blah\"\"@example.com", expectInvalid);
+emailCheck("\"testblah\"@example.com", "\"testblah\"@example.com", expectInvalid);
+emailCheck("[email protected]@", "[email protected]@", expectInvalid);
+emailCheck("someone@somewhere_com", "someone@somewhere_com", expectInvalid);
+emailCheck("someone@some:where.com", "someone@some:where.com", expectInvalid);
+emailCheck(".", ".", expectInvalid);
+emailCheck("F/s/f/a@feo+re.com", "F/s/f/a@feo+re.com", expectInvalid);
+emailCheck("some+long+email+address@some+host-weird-/looking.com", "some+long+email+address@some+host-weird-/looking.com", expectInvalid);
+emailCheck(" ", " ", expectInvalid);
+emailCheck(" [email protected]", " [email protected]", expectInvalid);
+emailCheck("[email protected] ", "[email protected] ", expectInvalid);
+emailCheck(" [email protected] ", " [email protected] ", expectInvalid);
+emailCheck("\[email protected]\u0020", "\[email protected]\u0020", expectInvalid);
+emailCheck("\[email protected]\u0009", "\[email protected]\u0009", expectInvalid);
+emailCheck("\[email protected]\u000B", "\[email protected]\u000B", expectInvalid);
+emailCheck("\[email protected]\u000C", "\[email protected]\u000C", expectInvalid);
+emailCheck("\[email protected]\u2003", "\[email protected]\u2003", expectInvalid);
+emailCheck("\[email protected]\u3000", "\[email protected]\u3000", expectInvalid);
+emailCheck("a @p.com", "a @p.com", expectInvalid);
+emailCheck("a\[email protected]", "a\[email protected]", expectInvalid);
+emailCheck("a\[email protected]", "a\[email protected]", expectInvalid);
+emailCheck("a\[email protected]", "a\[email protected]", expectInvalid);
+emailCheck("a\[email protected]", "a\[email protected]", expectInvalid);
+emailCheck("a\[email protected]", "a\[email protected]", expectInvalid);
+emailCheck("a\[email protected]", "a\[email protected]", expectInvalid);
 
-// VALID MULTIPLE
-emailCheck("[email protected],[email protected],[email protected],a/[email protected],[email protected]", false)
-emailCheck("tu!!7n7.ad##[email protected],F/s/f/[email protected],m*'@a.b", false)
-emailCheck(",,,,,,,,,,,", false)
+debug("Valid single addresses when 'multiple' attribute is set.");
+emailCheck("[email protected]", "[email protected]", expectValid, multiple);
+emailCheck("[email protected]", "[email protected]", expectValid, multiple);
+emailCheck("[email protected]", "[email protected]", expectValid, multiple);
+emailCheck("[email protected]", "[email protected]", expectValid, multiple);
+emailCheck("a/[email protected]", "a/[email protected]", expectValid, multiple);
+emailCheck("{}@domain.com", "{}@domain.com", expectValid, multiple);
+emailCheck("[email protected]", "[email protected]", expectValid, multiple);
+emailCheck("m*'!%@something.sa", "m*'!%@something.sa", expectValid, multiple);
+emailCheck("tu!!7n7.ad##[email protected]", "tu!!7n7.ad##[email protected]", expectValid, multiple);
+emailCheck("%@com.com", "%@com.com", expectValid, multiple);
+emailCheck("!#$%&'*+/=?^_`{|}[email protected]", "!#$%&'*+/=?^_`{|}[email protected]", expectValid, multiple);
+emailCheck("[email protected]", "[email protected]", expectValid, multiple);
+emailCheck("[email protected]", "[email protected]", expectValid, multiple);
+emailCheck("[email protected]", "[email protected]", expectValid, multiple);
+emailCheck("[email protected]", "[email protected]", expectValid, multiple);
+emailCheck("[email protected]", "[email protected]", expectValid, multiple);
+emailCheck("somebody@example", "somebody@example", expectValid, multiple);
+emailCheck("\[email protected]\u0020", "[email protected]", expectValid, multiple);
+emailCheck("\[email protected]\u0009", "[email protected]", expectValid, multiple);
+emailCheck("\[email protected]\u000A", "[email protected]", expectValid, multiple);
+emailCheck("\[email protected]\u000C", "[email protected]", expectValid, multiple);
+emailCheck("\[email protected]\u000D", "[email protected]", expectValid, multiple);
+emailCheck("a\[email protected]", "[email protected]", expectValid, multiple);
+emailCheck("a\[email protected]", "[email protected]", expectValid, multiple);
+emailCheck("", "", expectValid, multiple);
+emailCheck(" ", "", expectValid, multiple);
+emailCheck(" [email protected]", "[email protected]", expectValid, multiple);
+emailCheck("[email protected] ", "[email protected]", expectValid, multiple);
+emailCheck(" [email protected] ", "[email protected]", expectValid, multiple);
 
-// INVALID MULTIPLE (true on the first invalid occurrence)
-emailCheck("[email protected],[email protected],a@b,a/b@c,[email protected]", true)
-emailCheck("some+long+email+address@some+host:weird-/looking.com,F/s/f/a@feo+re.com,,m*'@'!%", true)
-emailCheck(",,,,,,,,, ,,", true)
+debug("Invalid single addresses when 'multiple' attribute is set.");
+emailCheck("invalid:[email protected]", "invalid:[email protected]", expectInvalid, multiple);
+emailCheck("@somewhere.com", "@somewhere.com", expectInvalid, multiple);
+emailCheck("example.com", "example.com", expectInvalid, multiple);
+emailCheck("@@example.com", "@@example.com", expectInvalid, multiple);
+emailCheck("a [email protected]", "a [email protected]", expectInvalid, multiple);
+emailCheck("[email protected]", "[email protected]", expectInvalid, multiple);
+emailCheck("a\b@c", "a\b@c", expectInvalid, multiple);
+emailCheck("[email protected].", "[email protected].", expectInvalid, multiple);
+emailCheck("\"\"test\blah\"\"@example.com", "\"\"test\blah\"\"@example.com", expectInvalid, multiple);
+emailCheck("\"testblah\"@example.com", "\"testblah\"@example.com", expectInvalid, multiple);
+emailCheck("[email protected]@", "[email protected]@", expectInvalid, multiple);
+emailCheck("someone@somewhere_com", "someone@somewhere_com", expectInvalid, multiple);
+emailCheck("someone@some:where.com", "someone@some:where.com", expectInvalid, multiple);
+emailCheck(".", ".", expectInvalid, multiple);
+emailCheck("F/s/f/a@feo+re.com", "F/s/f/a@feo+re.com", expectInvalid, multiple);
+emailCheck("some+long+email+address@some+host-weird-/looking.com", "some+long+email+address@some+host-weird-/looking.com", expectInvalid, multiple);
+emailCheck("\[email protected]\u000B", "\[email protected]\u000B", expectInvalid, multiple);
+emailCheck("\[email protected]\u2003", "\[email protected]\u2003", expectInvalid, multiple);
+emailCheck("\[email protected]\u3000", "\[email protected]\u3000", expectInvalid, multiple);
+emailCheck("a @p.com", "a @p.com", expectInvalid, multiple);
+emailCheck("a\[email protected]", "a\[email protected]", expectInvalid, multiple);
+emailCheck("a\[email protected]", "a\[email protected]", expectInvalid, multiple);
+emailCheck("a\[email protected]", "a\[email protected]", expectInvalid, multiple);
+emailCheck("a\[email protected]", "a\[email protected]", expectInvalid, multiple);
+emailCheck("a\[email protected]", "a\[email protected]", expectInvalid, multiple);
+emailCheck("a\[email protected]", "a\[email protected]", expectInvalid, multiple);
 
+debug("Valid multiple addresses when 'multiple' attribute is set.");
+emailCheck("[email protected],[email protected],[email protected],a/[email protected],[email protected]", "[email protected],[email protected],[email protected],a/[email protected],[email protected]", expectValid, multiple);
+emailCheck("tu!!7n7.ad##[email protected],F/s/f/[email protected],m*'@a.b", "tu!!7n7.ad##[email protected],F/s/f/[email protected],m*'@a.b", expectValid, multiple);
+emailCheck(" [email protected],[email protected]", "[email protected],[email protected]", expectValid, multiple);
+emailCheck("[email protected] ,[email protected]", "[email protected],[email protected]", expectValid, multiple);
+emailCheck("[email protected], [email protected]", "[email protected],[email protected]", expectValid, multiple);
+emailCheck("[email protected],[email protected] ", "[email protected],[email protected]", expectValid, multiple);
+emailCheck("   [email protected]   ,   [email protected]   ", "[email protected],[email protected]", expectValid, multiple);
+emailCheck("\[email protected]\u0020,\[email protected]\u0020", "[email protected],[email protected]", expectValid, multiple);
+emailCheck("\[email protected]\u0009,\[email protected]\u0009", "[email protected],[email protected]", expectValid, multiple);
+emailCheck("\[email protected]\u000A,\[email protected]\u000A", "[email protected],[email protected]", expectValid, multiple);
+emailCheck("\[email protected]\u000C,\[email protected]\u000C", "[email protected],[email protected]", expectValid, multiple);
+emailCheck("\[email protected]\u000D,\[email protected]\u000D", "[email protected],[email protected]", expectValid, multiple);
+
+debug("Invalid multiple addresses when 'multiple' attribute is set.");
+emailCheck("[email protected],[email protected],a@b,a/b@c,[email protected]", "[email protected],[email protected],a@b,a/b@c,[email protected]", expectInvalid, multiple);
+emailCheck("some+long+email+address@some+host:weird-/looking.com,F/s/f/a@feo+re.com,,m*'@'!%", "some+long+email+address@some+host:weird-/looking.com,F/s/f/a@feo+re.com,,m*'@'!%", expectInvalid, multiple);
+emailCheck("   a @p.com   ,   [email protected]   ", "a @p.com,[email protected]", expectInvalid, multiple);
+emailCheck("   [email protected]   ,   b @p.com   ", "[email protected],b @p.com", expectInvalid, multiple);
+emailCheck("\[email protected]\u000B,\[email protected]\u000B", "\[email protected]\u000B,\[email protected]\u000B", expectInvalid, multiple);
+emailCheck("\[email protected]\u2003,\[email protected]\u2003", "\[email protected]\u2003,\[email protected]\u2003", expectInvalid, multiple);
+emailCheck("\[email protected]\u3000,\[email protected]\u3000", "\[email protected]\u3000,\[email protected]\u3000", expectInvalid, multiple);
+emailCheck(",,", ",,", expectInvalid, multiple);
+emailCheck(" ,,", ",,", expectInvalid, multiple);
+emailCheck(", ,", ",,", expectInvalid, multiple);
+emailCheck(",, ", ",,", expectInvalid, multiple);
+emailCheck("  ,  ,  ", ",,", expectInvalid, multiple);
+emailCheck("\u0020,\u0020,\u0020", ",,", expectInvalid, multiple);
+emailCheck("\u0009,\u0009,\u0009", ",,", expectInvalid, multiple);
+emailCheck("\u000A,\u000A,\u000A", ",,", expectInvalid, multiple);
+emailCheck("\u000B,\u000B,\u000B", "\u000B,\u000B,\u000B", expectInvalid, multiple);
+emailCheck("\u000C,\u000C,\u000C", ",,", expectInvalid, multiple);
+emailCheck("\u000D,\u000D,\u000D", ",,", expectInvalid, multiple);
+emailCheck("\u2003,\u2003,\u2003", "\u2003,\u2003,\u2003", expectInvalid, multiple);
+emailCheck("\u3000,\u3000,\u3000", "\u3000,\u3000,\u3000", expectInvalid, multiple);
+
+
 var successfullyParsed = true;

Modified: trunk/Source/WebCore/ChangeLog (89914 => 89915)


--- trunk/Source/WebCore/ChangeLog	2011-06-28 09:44:49 UTC (rev 89914)
+++ trunk/Source/WebCore/ChangeLog	2011-06-28 09:46:08 UTC (rev 89915)
@@ -1,3 +1,26 @@
+2011-06-28  Kentaro Hara  <[email protected]>
+
+        Reviewed by Kent Tamura.
+
+        Allow spaces between e-mail addresses in 'email' input type.
+        https://bugs.webkit.org/show_bug.cgi?id=55987
+
+        Allowed spaces between e-mail addresses in 'email' input type,
+        e.g. ' [email protected] , [email protected] ' is a valid value. Implemented the
+        value sanitization algorithm for an e-mail value.  Added more unit
+        tests that check the e-mail value parser.
+
+        Test: fast/forms/ValidityState-typeMismatch-email.html
+
+        * html/EmailInputType.cpp:
+        (WebCore::EmailInputType::typeMismatchFor):
+        (WebCore::EmailInputType::sanitizeValue):
+        * html/EmailInputType.h:
+        * html/parser/HTMLParserIdioms.cpp:
+        (WebCore::stripHTMLLineBreaks):
+        * html/parser/HTMLParserIdioms.h:
+        (WebCore::isHTMLLineBreak):
+
 2011-06-28  Kent Tamura  <[email protected]>
 
         Reviewed by Hajime Morita.

Modified: trunk/Source/WebCore/html/EmailInputType.cpp (89914 => 89915)


--- trunk/Source/WebCore/html/EmailInputType.cpp	2011-06-28 09:44:49 UTC (rev 89914)
+++ trunk/Source/WebCore/html/EmailInputType.cpp	2011-06-28 09:46:08 UTC (rev 89915)
@@ -25,9 +25,11 @@
 #include "EmailInputType.h"
 
 #include "HTMLInputElement.h"
+#include "HTMLParserIdioms.h"
 #include "LocalizedStrings.h"
 #include "RegularExpression.h"
 #include <wtf/PassOwnPtr.h>
+#include <wtf/text/StringBuilder.h>
 
 namespace WebCore {
 
@@ -67,9 +69,9 @@
     if (!element()->multiple())
         return !isValidEmailAddress(value);
     Vector<String> addresses;
-    value.split(',', addresses);
+    value.split(',', true, addresses);
     for (unsigned i = 0; i < addresses.size(); ++i) {
-        if (!isValidEmailAddress(addresses[i]))
+        if (!isValidEmailAddress(stripLeadingAndTrailingHTMLSpaces(addresses[i])))
             return true;
     }
     return false;
@@ -90,4 +92,20 @@
     return true;
 }
 
+String EmailInputType::sanitizeValue(const String& proposedValue)
+{
+    String noLineBreakValue = proposedValue.removeCharacters(isHTMLLineBreak);
+    if (!element()->multiple())
+        return noLineBreakValue;
+    Vector<String> addresses;
+    noLineBreakValue.split(',', true, addresses);
+    StringBuilder strippedValue;
+    for (unsigned i = 0; i < addresses.size(); ++i) {
+        if (i > 0)
+            strippedValue.append(",");
+        strippedValue.append(stripLeadingAndTrailingHTMLSpaces(addresses[i]));
+    }
+    return strippedValue.toString();
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/html/EmailInputType.h (89914 => 89915)


--- trunk/Source/WebCore/html/EmailInputType.h	2011-06-28 09:44:49 UTC (rev 89914)
+++ trunk/Source/WebCore/html/EmailInputType.h	2011-06-28 09:46:08 UTC (rev 89915)
@@ -46,6 +46,7 @@
     virtual bool typeMismatch() const;
     virtual String typeMismatchText() const;
     virtual bool isEmailField() const;
+    virtual String sanitizeValue(const String&);
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/html/parser/HTMLParserIdioms.cpp (89914 => 89915)


--- trunk/Source/WebCore/html/parser/HTMLParserIdioms.cpp	2011-06-28 09:44:49 UTC (rev 89914)
+++ trunk/Source/WebCore/html/parser/HTMLParserIdioms.cpp	2011-06-28 09:46:08 UTC (rev 89915)
@@ -29,6 +29,7 @@
 #include <wtf/MathExtras.h>
 #include <wtf/dtoa.h>
 #include <wtf/text/AtomicString.h>
+#include <wtf/text/StringBuilder.h>
 
 namespace WebCore {
 

Modified: trunk/Source/WebCore/html/parser/HTMLParserIdioms.h (89914 => 89915)


--- trunk/Source/WebCore/html/parser/HTMLParserIdioms.h	2011-06-28 09:44:49 UTC (rev 89914)
+++ trunk/Source/WebCore/html/parser/HTMLParserIdioms.h	2011-06-28 09:46:08 UTC (rev 89915)
@@ -32,6 +32,7 @@
 
 // Space characters as defined by the HTML specification.
 bool isHTMLSpace(UChar);
+bool isHTMLLineBreak(UChar);
 bool isNotHTMLSpace(UChar);
 
 // Strip leading and trailing whitespace as defined by the HTML specification. 
@@ -66,6 +67,11 @@
     return character <= ' ' && (character == ' ' || character == '\n' || character == '\t' || character == '\r' || character == '\f');
 }
 
+inline bool isHTMLLineBreak(UChar character)
+{
+    return character <= '\r' && (character == '\n' || character == '\r');
+}
+
 inline bool isNotHTMLSpace(UChar character)
 {
     return !isHTMLSpace(character);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to