Changeset 93858 in webkit


Ignore:
Timestamp:
Aug 26, 2011 1:59:01 AM (13 years ago)
Author:
commit-queue@webkit.org
Message:

REGRESSION(r93390): Empty or invalid maxlength of an input tag should be ignored.
https://bugs.webkit.org/show_bug.cgi?id=67015

Patch by Shinya Kawanaka <shinyak@google.com> on 2011-08-26
Reviewed by Kent Tamura.

Source/WebCore:

  • html/HTMLInputElement.cpp:

(WebCore::HTMLInputElement::parseMaxLengthAttribute):

Checks the validity of maxlength attribute when converting it to integer.

LayoutTests:

  • fast/forms/input-text-paste-maxlength-expected.txt:

Added maxlength="" and maxlength="invalid" tests.

  • fast/forms/input-text-paste-maxlength.html: ditto.
  • fast/forms/script-tests/textarea-maxlength.js: ditto.
  • fast/forms/textarea-maxlength-expected.txt: ditto.
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r93855 r93858  
     12011-08-26  Shinya Kawanaka  <shinyak@google.com>
     2
     3        REGRESSION(r93390): Empty or invalid maxlength of an input tag should be ignored.
     4        https://bugs.webkit.org/show_bug.cgi?id=67015
     5
     6        Reviewed by Kent Tamura.
     7
     8        * fast/forms/input-text-paste-maxlength-expected.txt:
     9           Added maxlength="" and maxlength="invalid" tests.
     10        * fast/forms/input-text-paste-maxlength.html: ditto.
     11        * fast/forms/script-tests/textarea-maxlength.js: ditto.
     12        * fast/forms/textarea-maxlength-expected.txt: ditto.
     13
    1142011-08-25  Ben Wells  <benwells@chromium.org>
    215
  • trunk/LayoutTests/fast/forms/input-text-paste-maxlength-expected.txt

    r93390 r93858  
    2929PASS domValueOf('l') is ''
    3030PASS visibleValueOf('l') is ''
     31empty maxlength should be ignored.
     32PASS domValueOf('m') is '12' + fancyX + '45'
     33PASS visibleValueOf('m') is '12' + fancyX + '45'
     34invalid maxlength should be ignored.
     35PASS domValueOf('n') is '12' + fancyX + '45'
     36PASS visibleValueOf('n') is '12' + fancyX + '45'
    3137PASS successfullyParsed is true
    3238
    3339TEST COMPLETE
    34          
     40          
  • trunk/LayoutTests/fast/forms/input-text-paste-maxlength.html

    r93390 r93858  
    1919<input type="text" id="k" size="5" maxlength="4">
    2020<input type="text" id="l" size="5" maxlength="0">
     21<input type="text" id="m" size="5" maxlength="">
     22<input type="text" id="n" size="5" maxlength="invalid">
    2123
    2224<script>
     
    101103shouldBe("visibleValueOf('l')", "''");
    102104
     105debug("empty maxlength should be ignored.");
     106document.getElementById("m").focus();
     107document.execCommand("InsertHTML", false, "12x&#x305;&#x332;45");
     108shouldBe("domValueOf('m')", "'12' + fancyX + '45'");
     109shouldBe("visibleValueOf('m')", "'12' + fancyX + '45'");
     110
     111debug("invalid maxlength should be ignored.");
     112document.getElementById("n").focus();
     113document.execCommand("InsertHTML", false, "12x&#x305;&#x332;45");
     114shouldBe("domValueOf('n')", "'12' + fancyX + '45'");
     115shouldBe("visibleValueOf('n')", "'12' + fancyX + '45'");
     116
    103117var successfullyParsed = true;
    104118</script>
  • trunk/LayoutTests/fast/forms/script-tests/textarea-maxlength.js

    r93390 r93858  
    141141shouldBe('textArea.value', '""');
    142142
     143// In the case maxlength=''
     144createFocusedTextAreaWithMaxLength('');
     145textArea.value = '';
     146document.execCommand('insertText', false, 'ABC');
     147shouldBe('textArea.value', '"ABC"');
     148
     149// In the case maxlength='invalid'
     150createFocusedTextAreaWithMaxLength('invalid');
     151textArea.value = '';
     152document.execCommand('insertText', false, 'ABC');
     153shouldBe('textArea.value', '"ABC"');
     154
    143155var successfullyParsed = true;
  • trunk/LayoutTests/fast/forms/textarea-maxlength-expected.txt

    r93390 r93858  
    3131PASS textArea.value is "ABC"
    3232PASS textArea.value is ""
     33PASS textArea.value is "ABC"
     34PASS textArea.value is "ABC"
    3335PASS successfullyParsed is true
    3436
  • trunk/Source/WebCore/ChangeLog

    r93856 r93858  
     12011-08-26  Shinya Kawanaka  <shinyak@google.com>
     2
     3        REGRESSION(r93390): Empty or invalid maxlength of an input tag should be ignored.
     4        https://bugs.webkit.org/show_bug.cgi?id=67015
     5
     6        Reviewed by Kent Tamura.
     7
     8        * html/HTMLInputElement.cpp:
     9        (WebCore::HTMLInputElement::parseMaxLengthAttribute):
     10          Checks the validity of maxlength attribute when converting it to integer.
     11
    1122011-08-25  Yuta Kitamura  <yutak@chromium.org>
    213
  • trunk/Source/WebCore/html/HTMLInputElement.cpp

    r93390 r93858  
    19221922void HTMLInputElement::parseMaxLengthAttribute(Attribute* attribute)
    19231923{
    1924     int maxLength = attribute->isNull() ? maximumLength : attribute->value().toInt();
     1924    int maxLength;
     1925    if (!parseHTMLInteger(attribute->value(), maxLength))
     1926        maxLength = maximumLength;
    19251927    if (maxLength < 0 || maxLength > maximumLength)
    19261928        maxLength = maximumLength;
Note: See TracChangeset for help on using the changeset viewer.