Title: [121401] trunk
Revision
121401
Author
[email protected]
Date
2012-06-27 20:58:02 -0700 (Wed, 27 Jun 2012)

Log Message

pattern="" should only accept the empty string
https://bugs.webkit.org/show_bug.cgi?id=89569

Patch by Pablo Flouret <[email protected]> on 2012-06-27
Reviewed by Kent Tamura.

Source/WebCore:

An empty pattern attribute was being treated essentially as if the
pattern wasn't present.

No new tests. Covered by existing tests (plus a modified one).

* html/BaseTextInputType.cpp:
(WebCore::BaseTextInputType::patternMismatch):
    Check if the pattern attribute is present. If it is then use the
    pattern as is (in the particular case of this bug, an empty pattern
    will only match an empty value).

LayoutTests:

* fast/forms/ValidityState-patternMismatch-expected.txt:
* fast/forms/ValidityState-patternMismatch.html:
    Modified the test to check the results of an empty pattern both with an empty
    value, and with some value specified.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (121400 => 121401)


--- trunk/LayoutTests/ChangeLog	2012-06-28 03:33:01 UTC (rev 121400)
+++ trunk/LayoutTests/ChangeLog	2012-06-28 03:58:02 UTC (rev 121401)
@@ -1,3 +1,15 @@
+2012-06-27  Pablo Flouret  <[email protected]>
+
+        pattern="" should only accept the empty string
+        https://bugs.webkit.org/show_bug.cgi?id=89569
+
+        Reviewed by Kent Tamura.
+
+        * fast/forms/ValidityState-patternMismatch-expected.txt:
+        * fast/forms/ValidityState-patternMismatch.html:
+            Modified the test to check the results of an empty pattern both with an empty
+            value, and with some value specified.
+
 2012-06-27  Alexis Menard  <[email protected]>
 
         Implement selectedOptions attribute of HTMLSelectElement.

Modified: trunk/LayoutTests/fast/forms/ValidityState-patternMismatch-expected.txt (121400 => 121401)


--- trunk/LayoutTests/fast/forms/ValidityState-patternMismatch-expected.txt	2012-06-28 03:33:01 UTC (rev 121400)
+++ trunk/LayoutTests/fast/forms/ValidityState-patternMismatch-expected.txt	2012-06-28 03:58:02 UTC (rev 121401)
@@ -51,7 +51,8 @@
 PASS patternMismatchFor("mismatch-18") is true
 PASS patternMismatchFor("mismatch-19") is true
 PASS patternMismatchFor("mismatch-20") is true
-PASS patternMismatchFor("empty-pattern") is false
+PASS patternMismatchFor("empty-pattern-match") is false
+PASS patternMismatchFor("empty-pattern-mismatch") is true
 PASS patternMismatchFor("disabled") is false
 PASS successfullyParsed is true
 

Modified: trunk/LayoutTests/fast/forms/ValidityState-patternMismatch.html (121400 => 121401)


--- trunk/LayoutTests/fast/forms/ValidityState-patternMismatch.html	2012-06-28 03:33:01 UTC (rev 121400)
+++ trunk/LayoutTests/fast/forms/ValidityState-patternMismatch.html	2012-06-28 03:58:02 UTC (rev 121401)
@@ -31,6 +31,7 @@
 /><input id="match-17" type="text" pattern="foobar" value="" />
 <input id="match-18" type="text" pattern="[0-9]|10|11|12" value="10" />
 <input id="match-19" type="text" pattern="10|11|12|[0-9]" value="12" />
+<input id="empty-pattern-match" type="text" pattern="" value="" />
 <input id="wrong-gray-or-grey" type="text" pattern="gr[ae]y" value="Wrong!"
 /><input id="gray" type="text" pattern="gr[ae]y" value="gray"
 /><input id="grey" type="text" pattern="gr[ae]y" value="grey"
@@ -55,7 +56,7 @@
 /><input id="mismatch-18" type="text" pattern="foo\\" value="food"
 /><input id="mismatch-19" type="text" pattern="^" value="wrong"
 /><input id="mismatch-20" type="text" pattern="$" value="wrong"
-/><input id="empty-pattern" type="text" pattern="" value="Lorem Ipsum"
+/><input id="empty-pattern-mismatch" type="text" pattern="" value="Lorem Ipsum"
 /><input id="disabled" pattern="[0-9][A-Z]{3}" value="00AA" disabled /></div>
 <script language="_javascript_" type="text/_javascript_">
 function patternMismatchFor(id) {
@@ -116,7 +117,8 @@
 shouldBeTrue('patternMismatchFor("mismatch-19")');
 shouldBeTrue('patternMismatchFor("mismatch-20")');
 
-shouldBeFalse('patternMismatchFor("empty-pattern")');
+shouldBeFalse('patternMismatchFor("empty-pattern-match")');
+shouldBeTrue('patternMismatchFor("empty-pattern-mismatch")');
 
 shouldBeFalse('patternMismatchFor("disabled")');
 

Modified: trunk/Source/WebCore/ChangeLog (121400 => 121401)


--- trunk/Source/WebCore/ChangeLog	2012-06-28 03:33:01 UTC (rev 121400)
+++ trunk/Source/WebCore/ChangeLog	2012-06-28 03:58:02 UTC (rev 121401)
@@ -1,3 +1,21 @@
+2012-06-27  Pablo Flouret  <[email protected]>
+
+        pattern="" should only accept the empty string
+        https://bugs.webkit.org/show_bug.cgi?id=89569
+
+        Reviewed by Kent Tamura.
+
+        An empty pattern attribute was being treated essentially as if the
+        pattern wasn't present.
+
+        No new tests. Covered by existing tests (plus a modified one).
+
+        * html/BaseTextInputType.cpp:
+        (WebCore::BaseTextInputType::patternMismatch):
+            Check if the pattern attribute is present. If it is then use the
+            pattern as is (in the particular case of this bug, an empty pattern
+            will only match an empty value).
+
 2012-06-27  James Robinson  <[email protected]>
 
         [chromium] Use SkColor in compositor internals

Modified: trunk/Source/WebCore/html/BaseTextInputType.cpp (121400 => 121401)


--- trunk/Source/WebCore/html/BaseTextInputType.cpp	2012-06-28 03:33:01 UTC (rev 121400)
+++ trunk/Source/WebCore/html/BaseTextInputType.cpp	2012-06-28 03:58:02 UTC (rev 121401)
@@ -41,7 +41,7 @@
 {
     const AtomicString& rawPattern = element()->fastGetAttribute(patternAttr);
     // Empty values can't be mismatched
-    if (rawPattern.isEmpty() || value.isEmpty())
+    if (rawPattern.isNull() || value.isEmpty())
         return false;
     String pattern = "^(" + rawPattern + ")$";
     int matchLength = 0;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to