Changeset 148614 in webkit


Ignore:
Timestamp:
Apr 17, 2013 9:14:37 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

getAttribute does not behave correctly for mixed-case attributes on HTML elements
https://bugs.webkit.org/show_bug.cgi?id=105713

Patch by Arpita Bahuguna <a.bah@samsung.com> on 2013-04-17
Reviewed by Andreas Kling.

Source/WebCore:

getAttribute() and getAttributeNode() APIs do not convert the
passed attribute name to lowercase before comparing against the
existing attributes.
The specification however states that the passed name should
be converted to ASCII lowercase before checking for the existence
of the given attribute. [www.w3.org/TR/domcore/#dom-element-getattribute]

Test: fast/dom/Element/getAttribute-case-insensitivity.html

  • dom/Element.h:

(WebCore::ElementData::getAttributeItemIndex):
getAttributeItemIndex() accepts a bool param 'shouldIgnoreAttributeCase'
which specifies whether or not the attribute's case should be ignored
before comparison but we don't really convert the passed name to lowercase
before carrying out the comparison.

Thus, when called from APIs such as getAttribute() and getAttributeNode()
which do not explicitally convert the attribute name to lowercase
before calling on this method, it fails to carry out a case-insensitive
search.

Have thus made changes to convert the passed attribute's name to
lowercase if 'shouldIgnoreAttributeCase' is true.

LayoutTests:

  • fast/dom/Element/getAttribute-case-insensitivity-expected.txt: Added.
  • fast/dom/Element/getAttribute-case-insensitivity.html: Added.

Layout test added for verifying that getAttribute() and getAttributeNode()
APIs convert the passed attribute name to lowercase before comparing
against the existing attributes.

Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r148612 r148614  
     12013-04-17  Arpita Bahuguna  <a.bah@samsung.com>
     2
     3        getAttribute does not behave correctly for mixed-case attributes on HTML elements
     4        https://bugs.webkit.org/show_bug.cgi?id=105713
     5
     6        Reviewed by Andreas Kling.
     7
     8        * fast/dom/Element/getAttribute-case-insensitivity-expected.txt: Added.
     9        * fast/dom/Element/getAttribute-case-insensitivity.html: Added.
     10        Layout test added for verifying that getAttribute() and getAttributeNode()
     11        APIs convert the passed attribute name to lowercase before comparing
     12        against the existing attributes.
     13
    1142013-04-17  Zoltan Arvai  <zarvai@inf.u-szeged.hu>
    215
  • trunk/Source/WebCore/ChangeLog

    r148613 r148614  
     12013-04-17  Arpita Bahuguna  <a.bah@samsung.com>
     2
     3        getAttribute does not behave correctly for mixed-case attributes on HTML elements
     4        https://bugs.webkit.org/show_bug.cgi?id=105713
     5
     6        Reviewed by Andreas Kling.
     7
     8        getAttribute() and getAttributeNode() APIs do not convert the
     9        passed attribute name to lowercase before comparing against the
     10        existing attributes.
     11        The specification however states that the passed name should
     12        be converted to ASCII lowercase before checking for the existence
     13        of the given attribute. [www.w3.org/TR/domcore/#dom-element-getattribute]
     14
     15        Test: fast/dom/Element/getAttribute-case-insensitivity.html
     16
     17        * dom/Element.h:
     18        (WebCore::ElementData::getAttributeItemIndex):
     19        getAttributeItemIndex() accepts a bool param 'shouldIgnoreAttributeCase'
     20        which specifies whether or not the attribute's case should be ignored
     21        before comparison but we don't really convert the passed name to lowercase
     22        before carrying out the comparison.
     23
     24        Thus, when called from APIs such as getAttribute() and getAttributeNode()
     25        which do not explicitally convert the attribute name to lowercase
     26        before calling on this method, it fails to carry out a case-insensitive
     27        search.
     28
     29        Have thus made changes to convert the passed attribute's name to
     30        lowercase if 'shouldIgnoreAttributeCase' is true.
     31
    1322013-04-17  John Griggs  <jgriggs@blackberry.com>
    233
  • trunk/Source/WebCore/dom/Element.h

    r147983 r148614  
    976976    bool doSlowCheck = shouldIgnoreAttributeCase;
    977977
     978    const AtomicString caseAdjustedName = shouldIgnoreAttributeCase ? name.lower() : name;
    978979    // Optimize for the case where the attribute exists and its name exactly matches.
    979980    for (unsigned i = 0; i < len; ++i) {
    980981        const Attribute* attribute = attributeItem(i);
    981982        if (!attribute->name().hasPrefix()) {
    982             if (name == attribute->localName())
     983            if (caseAdjustedName == attribute->localName())
    983984                return i;
    984985        } else
Note: See TracChangeset for help on using the changeset viewer.