Bug 89569 - pattern="" should only accept the empty string
Summary: pattern="" should only accept the empty string
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Pablo Flouret
URL:
Keywords: WebExposed
Depends on:
Blocks:
 
Reported: 2012-06-20 06:59 PDT by Jacob Rask
Modified: 2012-06-27 21:17 PDT (History)
3 users (show)

See Also:


Attachments
Patch (5.16 KB, patch)
2012-06-26 17:08 PDT, Pablo Flouret
no flags Details | Formatted Diff | Diff
Patch (5.13 KB, patch)
2012-06-27 17:22 PDT, Pablo Flouret
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jacob Rask 2012-06-20 06:59:48 PDT
Setting pattern to "" makes any value valid.

http://jsfiddle.net/z7tb9/
Comment 1 Kent Tamura 2012-06-20 13:37:27 PDT
Confirmed.
Comment 2 Pablo Flouret 2012-06-26 17:08:42 PDT
Created attachment 149638 [details]
Patch
Comment 3 Darin Adler 2012-06-26 17:57:42 PDT
Comment on attachment 149638 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=149638&action=review

Good fix. Need to do it slightly differently, though.

> Source/WebCore/html/BaseTextInputType.cpp:44
> -    if (rawPattern.isEmpty() || value.isEmpty())
> +    if (!element()->fastHasAttribute(patternAttr) || value.isEmpty())

The correct way to check this is:

    if (rawPattern.isNull() || value.isEmpty())

There’s no need for a fastHasAttribute call, which will do another attribute hash table lookup.
Comment 4 Pablo Flouret 2012-06-27 17:22:57 PDT
Created attachment 149830 [details]
Patch

Fixed the test condition per Darin's helpful comments.
Comment 5 Kent Tamura 2012-06-27 20:40:35 PDT
Comment on attachment 149830 [details]
Patch

Looks nice.  Thank you!
Comment 6 WebKit Review Bot 2012-06-27 20:58:17 PDT
Comment on attachment 149830 [details]
Patch

Clearing flags on attachment: 149830

Committed r121401: <http://trac.webkit.org/changeset/121401>
Comment 7 WebKit Review Bot 2012-06-27 20:58:22 PDT
All reviewed patches have been landed.  Closing bug.