[webkit-changes] [WebKit/WebKit] 9743d1: HTML maxlength attribute treats emoji of string le...

Chris Dumez noreply at github.com
Sat Feb 25 10:13:51 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 9743d10df7bc729130bf6bb1fa975aec17e71bc3
      https://github.com/WebKit/WebKit/commit/9743d10df7bc729130bf6bb1fa975aec17e71bc3
  Author: Chris Dumez <cdumez at apple.com>
  Date:   2023-02-25 (Sat, 25 Feb 2023)

  Changed paths:
    M LayoutTests/fast/forms/input-maxlength-paste-clusters-in-middle-expected.txt
    M LayoutTests/fast/forms/input-maxlength-paste-clusters-in-middle.html
    A LayoutTests/fast/forms/input-text-max-length-emojis-expected.txt
    A LayoutTests/fast/forms/input-text-max-length-emojis.html
    M LayoutTests/fast/forms/input-text-paste-maxlength-expected.txt
    M LayoutTests/fast/forms/input-text-paste-maxlength.html
    A LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/input-maxlength-emoji-expected.txt
    A LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/input-maxlength-emoji.html
    M LayoutTests/platform/glib/TestExpectations
    M Source/WebCore/html/HTMLInputElement.cpp
    M Source/WebCore/html/HTMLTextAreaElement.cpp
    M Source/WebCore/html/InputType.cpp
    M Source/WebCore/html/TextFieldInputType.cpp
    M Tools/WebKitTestRunner/gtk/UIScriptControllerGtk.cpp
    M Tools/WebKitTestRunner/gtk/UIScriptControllerGtk.h

  Log Message:
  -----------
  HTML maxlength attribute treats emoji of string length 11 as length 1
https://bugs.webkit.org/show_bug.cgi?id=252900

Reviewed by Ryosuke Niwa and Aditya Keerthi.

Per the HTML specification[1], minlength/maxlength attributes on <input> should
restrict the length of the value, which is defined in code units [2].

Historically, WebKit has been counting grapheme clusters instead of code units
because we felt it made more sense. However, Blink and Gecko follow the
specification and only WebKit has the particular behavior. This is bad for
interoperability and makes Web developers' life more difficult than it needs to
be.

As a result, I am proposing we update WebKit to align with the HTML
specification and other major browser engines.

[1] https://html.spec.whatwg.org/multipage/input.html#the-maxlength-and-minlength-attributes
[2] https://infra.spec.whatwg.org/#string-length

* LayoutTests/fast/forms/input-maxlength-paste-clusters-in-middle-expected.txt:
* LayoutTests/fast/forms/input-maxlength-paste-clusters-in-middle.html:
* LayoutTests/fast/forms/input-text-max-length-emojis-expected.txt: Added.
* LayoutTests/fast/forms/input-text-max-length-emojis.html: Added.
* LayoutTests/fast/forms/input-text-paste-maxlength-expected.txt:
* LayoutTests/fast/forms/input-text-paste-maxlength.html:
* Source/WebCore/html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::tooShort const):
(WebCore::HTMLInputElement::tooLong const):
* Source/WebCore/html/HTMLTextAreaElement.cpp:
(WebCore::computeLengthForSubmission):
* Source/WebCore/html/InputType.cpp:
(WebCore::InputType::validationMessage const):
* Source/WebCore/html/TextFieldInputType.cpp:
(WebCore::limitLength):
(WebCore::TextFieldInputType::handleBeforeTextInsertedEvent):

Canonical link: https://commits.webkit.org/260838@main




More information about the webkit-changes mailing list