[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.15.1-1414-gc69ee75

eric at webkit.org eric at webkit.org
Thu Oct 29 20:43:55 UTC 2009


The following commit has been merged in the webkit-1.1 branch:
commit 5c1f28006cc1fd363253f4ce3e4e9a1ac1ee2e5d
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Oct 13 20:53:12 2009 +0000

    2009-10-13  Michelangelo De Simone  <micdesim at gmail.com>
    
            Reviewed by Adam Barth.
    
            https://bugs.webkit.org/show_bug.cgi?id=27457
            Test case for static email validation on type=email input elements as
            per HTML5 specs:
            http://www.whatwg.org/specs/web-apps/current-work/#e-mail-state
    
            * fast/forms/ValidityState-typeMismatch-email-expected.txt: Added.
            * fast/forms/ValidityState-typeMismatch-email.html: Added.
            * fast/forms/resources/ValidityState-typeMismatch-email.js: Added.
            ():
    2009-10-13  Michelangelo De Simone  <micdesim at gmail.com>
    
            Reviewed by Adam Barth.
    
            https://bugs.webkit.org/show_bug.cgi?id=27457
            Added support for static validation on type=email input elements as per
            HTML5 specs:
            http://www.whatwg.org/specs/web-apps/current-work/#e-mail-state
    
            Test: fast/forms/ValidityState-typeMismatch-email.html
    
            * html/ValidityState.cpp:
            (WebCore::ValidityState::typeMismatch): ValidityState.typeMismatch
            performs validation on type=email input elements now.
            (WebCore::ValidityState::isValidEmailAddress): simple validation method
            * html/ValidityState.h:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@49508 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 1fc0702..ae37ec9 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,17 @@
+2009-10-13  Michelangelo De Simone  <micdesim at gmail.com>
+
+        Reviewed by Adam Barth.
+
+        https://bugs.webkit.org/show_bug.cgi?id=27457
+        Test case for static email validation on type=email input elements as
+        per HTML5 specs:
+        http://www.whatwg.org/specs/web-apps/current-work/#e-mail-state
+
+        * fast/forms/ValidityState-typeMismatch-email-expected.txt: Added.
+        * fast/forms/ValidityState-typeMismatch-email.html: Added.
+        * fast/forms/resources/ValidityState-typeMismatch-email.js: Added.
+        ():
+
 2009-10-13  Dmitry Titov  <dimich at chromium.org>
 
         Reviewed by Adam Barth.
diff --git a/LayoutTests/fast/forms/ValidityState-typeMismatch-email-expected.txt b/LayoutTests/fast/forms/ValidityState-typeMismatch-email-expected.txt
new file mode 100644
index 0000000..f8431c4
--- /dev/null
+++ b/LayoutTests/fast/forms/ValidityState-typeMismatch-email-expected.txt
@@ -0,0 +1,47 @@
+This test aims to check for typeMismatch flag with type=email input fields.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS something at something.com is a correct valid email address 
+PASS someone at localhost.localdomain is a correct valid email address 
+PASS someone at 127.0.0.1 is a correct valid email address 
+PASS a at b.b is a correct valid email address 
+PASS a/b at domain.com is a correct valid email address 
+PASS {}@domain.com is a correct valid email address 
+PASS ddjk-s-jk at asl-.com is a correct valid email address 
+PASS m*'!%@something.sa is a correct valid email address 
+PASS tu!!7n7.ad##0!!!@company.ca is a correct valid email address 
+PASS %@com.com is a correct valid email address 
+PASS !#$%&'*+/=?^_`{|}~.- at com.com is a correct valid email address 
+PASS .wooly at example.com is a correct valid email address 
+PASS wo..oly at example.com is a correct valid email address 
+PASS someone at do-ma-in.com is a correct valid email address 
+PASS someone at do-.com is a correct valid email address 
+PASS somebody at -.com is a correct valid email address 
+PASS invalid:email at example.com 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 space at example.com is a correct invalid email address 
+PASS something at ex..ample.com is a correct invalid email address 
+PASS a@c is a correct invalid email address 
+PASS someone at somewhere.com. 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 someone at somewhere.com@ is a correct invalid email address 
+PASS someone at somewhere_com is a correct invalid email address 
+PASS someone at some:where.com is a correct invalid email address 
+PASS . is a correct invalid email address 
+PASS F/s/f/a at feo+re.com is a correct invalid email address 
+PASS some+long+email+address at some+host-weird-/looking.com is a correct invalid email address 
+PASS someone at somewhere.com,john at doe.com,a at b.c,a/b at c.c,ualla at ualla.127 is a correct valid email address list
+PASS tu!!7n7.ad##0!!!@company.ca,F/s/f/a at feo-re.com,m*'@a.b is a correct valid email address list
+PASS ,,,,,,,,,,, is a correct valid email address list
+PASS someone at somewhere.com,john at doe..com,a at b,a/b at c,ualla at ualla.127 is a correct invalid email address list
+PASS some+long+email+address at some+host:weird-/looking.com,F/s/f/a at feo+re.com,,m*'@'!% is a correct invalid email address list
+PASS ,,,,,,,,, ,, is a correct invalid email address list
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/forms/ValidityState-typeMismatch-email.html b/LayoutTests/fast/forms/ValidityState-typeMismatch-email.html
new file mode 100644
index 0000000..336acc0
--- /dev/null
+++ b/LayoutTests/fast/forms/ValidityState-typeMismatch-email.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="resources/ValidityState-typeMismatch-email.js"></script>
+<script src="../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/forms/resources/ValidityState-typeMismatch-email.js b/LayoutTests/fast/forms/resources/ValidityState-typeMismatch-email.js
new file mode 100644
index 0000000..b4d6e90
--- /dev/null
+++ b/LayoutTests/fast/forms/resources/ValidityState-typeMismatch-email.js
@@ -0,0 +1,69 @@
+description("This test aims to check for typeMismatch flag with type=email input fields.");
+
+var i = document.createElement('input');
+i.type = 'email';
+
+function emailCheck(val, expectedValid)
+{
+    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);
+    else
+        testFailed(resultText);
+}
+
+// VALID
+emailCheck("something at something.com", false);
+emailCheck("someone at localhost.localdomain", false);
+emailCheck("someone at 127.0.0.1", false);
+emailCheck("a at b.b", false);
+emailCheck("a/b at domain.com", false);
+emailCheck("{}@domain.com", false);
+emailCheck("ddjk-s-jk at asl-.com", false);
+emailCheck("m*'!%@something.sa", false);
+emailCheck("tu!!7n7.ad##0!!!@company.ca", false);
+emailCheck("%@com.com", false);
+emailCheck("!#$%&'*+/=?^_`{|}~.- at com.com", false);
+emailCheck(".wooly at example.com", false);
+emailCheck("wo..oly at example.com", false);
+emailCheck("someone at do-ma-in.com", false);
+emailCheck("someone at do-.com", false);
+emailCheck("somebody at -.com", false);
+
+// INVALID
+emailCheck("invalid:email at example.com", true);
+emailCheck("@somewhere.com", true);
+emailCheck("example.com", true);
+emailCheck("@@example.com", true);
+emailCheck("a space at example.com", true);
+emailCheck("something at ex..ample.com", true);
+emailCheck("a\b at c", true);
+emailCheck("someone at somewhere.com.", true);
+emailCheck("\"\"test\blah\"\"@example.com", true);
+emailCheck("\"testblah\"@example.com", true);
+emailCheck("someone at somewhere.com@", true);
+emailCheck("someone at somewhere_com", true);
+emailCheck("someone at some:where.com", true);
+emailCheck(".", true);
+emailCheck("F/s/f/a at feo+re.com", true);
+emailCheck("some+long+email+address at some+host-weird-/looking.com", true);
+
+i.multiple = true;
+
+// VALID MULTIPLE
+emailCheck("someone at somewhere.com,john at doe.com,a at b.c,a/b at c.c,ualla at ualla.127", false)
+emailCheck("tu!!7n7.ad##0!!!@company.ca,F/s/f/a at feo-re.com,m*'@a.b", false)
+emailCheck(",,,,,,,,,,,", false)
+
+// INVALID MULTIPLE (true on the first invalid occurrence)
+emailCheck("someone at somewhere.com,john at doe..com,a at b,a/b at c,ualla at ualla.127", true)
+emailCheck("some+long+email+address at some+host:weird-/looking.com,F/s/f/a at feo+re.com,,m*'@'!%", true)
+emailCheck(",,,,,,,,, ,,", true)
+
+var successfullyParsed = true;
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 48f5840..7839630 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,20 @@
+2009-10-13  Michelangelo De Simone  <micdesim at gmail.com>
+
+        Reviewed by Adam Barth.
+
+        https://bugs.webkit.org/show_bug.cgi?id=27457
+        Added support for static validation on type=email input elements as per
+        HTML5 specs:
+        http://www.whatwg.org/specs/web-apps/current-work/#e-mail-state
+
+        Test: fast/forms/ValidityState-typeMismatch-email.html
+
+        * html/ValidityState.cpp:
+        (WebCore::ValidityState::typeMismatch): ValidityState.typeMismatch
+        performs validation on type=email input elements now.
+        (WebCore::ValidityState::isValidEmailAddress): simple validation method 
+        * html/ValidityState.h:
+
 2009-10-13  Dmitry Titov  <dimich at chromium.org>
 
         Reviewed by Adam Barth.
diff --git a/WebCore/html/ValidityState.cpp b/WebCore/html/ValidityState.cpp
index 5bf8382..6b0a0b4 100644
--- a/WebCore/html/ValidityState.cpp
+++ b/WebCore/html/ValidityState.cpp
@@ -26,6 +26,12 @@
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
 #include "KURL.h"
+#include "RegularExpression.h"
+#include <wtf/StdLibExtras.h>
+
+#define EMAIL_LOCALPART "[a-z0-9!#$%&'*+/=?^_`{|}~.-]+"
+#define EMAIL_DOMAINPART "[a-z0-9-]+(\\.[a-z0-9-]+)+"
+#define EMAIL_PATTERN EMAIL_LOCALPART "@" EMAIL_DOMAINPART
 
 namespace WebCore {
 
@@ -55,6 +61,19 @@ bool ValidityState::typeMismatch()
         return !HTMLInputElement::formStringToDouble(value, 0);
     case HTMLInputElement::URL:
         return !KURL(KURL(), value).isValid();
+    case HTMLInputElement::EMAIL:
+    {
+        if (!input->multiple())
+            return !isValidEmailAddress(value);
+            
+        Vector<String> email_list;
+        value.split(',', email_list);
+        for (unsigned i = 0; i < email_list.size(); ++i)
+            if (!isValidEmailAddress(email_list[i]))
+                return true;
+
+        return false;
+    }
     default:
         return false;
     }
@@ -95,4 +114,19 @@ bool ValidityState::isValidColorString(const String& value)
     return color.isValid() && !color.hasAlpha();
 }
 
+bool ValidityState::isValidEmailAddress(const String& email)
+{
+    if (email.isEmpty())
+        return false;
+
+    DEFINE_STATIC_LOCAL(AtomicString, emailPattern, (EMAIL_PATTERN));
+    DEFINE_STATIC_LOCAL(RegularExpression, regExp, (emailPattern, TextCaseInsensitive));
+
+    int matchLength = 0;
+    int emailLength = email.length();
+    int matchOffset = regExp.match(email, 0, &matchLength);
+
+    return matchOffset == 0 && matchLength == emailLength;
+}
+
 } // namespace
diff --git a/WebCore/html/ValidityState.h b/WebCore/html/ValidityState.h
index 67afa53..1dee306 100644
--- a/WebCore/html/ValidityState.h
+++ b/WebCore/html/ValidityState.h
@@ -56,6 +56,7 @@ namespace WebCore {
         String m_customErrorMessage;
 
         static bool isValidColorString(const String&);
+        bool isValidEmailAddress(const String&);
     };
 
 } // namespace WebCore

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list