Changeset 149106 in webkit


Ignore:
Timestamp:
Apr 25, 2013 6:43:33 AM (11 years ago)
Author:
akling@apple.com
Message:

CSS parser: Add error recovery while parsing @-webkit-keyframes key values.
<http://webkit.org/b/115175>

Source/WebCore:

From Blink r148714 by <apavlov@chromium.org>:

If not a percentage, "from", or "to" value is used in a key list, the rule is erroneous,
and due to the absense of recovery, the parser skips the following, valid CSS rule.

On a related note, keyframes, whose selectors contain invalid keys, should be discarded
altogether, according to <http://www.w3.org/TR/css3-animations/#keyframes>

Tests: animations/keyframes-invalid-keys.html

fast/css/webkit-keyframes-errors.html

  • css/CSSGrammar.y.in:
  • css/CSSParser.cpp:

(WebCore::CSSParser::rewriteSpecifiers):

LayoutTests:

From Blink r148714 by <apavlov@chromium.org>.

  • animations/keyframes-invalid-keys-expected.txt: Added.
  • animations/keyframes-invalid-keys.html: Added.
  • fast/css/webkit-keyframes-errors-expected.html: Added.
  • fast/css/webkit-keyframes-errors.html: Added.
Location:
trunk
Files:
4 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r149104 r149106  
     12013-04-25  Andreas Kling  <akling@apple.com>
     2
     3        CSS parser: Add error recovery while parsing @-webkit-keyframes key values.
     4        <http://webkit.org/b/115175>
     5
     6        From Blink r148714 by <apavlov@chromium.org>.
     7
     8        * animations/keyframes-invalid-keys-expected.txt: Added.
     9        * animations/keyframes-invalid-keys.html: Added.
     10        * fast/css/webkit-keyframes-errors-expected.html: Added.
     11        * fast/css/webkit-keyframes-errors.html: Added.
     12
    1132013-04-25  Ádám Kallai  <kadam@inf.u-szeged.hu>
    214
  • trunk/Source/WebCore/ChangeLog

    r149105 r149106  
     12013-04-25  Andreas Kling  <akling@apple.com>
     2
     3        CSS parser: Add error recovery while parsing @-webkit-keyframes key values.
     4        <http://webkit.org/b/115175>
     5
     6        From Blink r148714 by <apavlov@chromium.org>:
     7
     8        If not a percentage, "from", or "to" value is used in a key list, the rule is erroneous,
     9        and due to the absense of recovery, the parser skips the following, valid CSS rule.
     10
     11        On a related note, keyframes, whose selectors contain invalid keys, should be discarded
     12        altogether, according to <http://www.w3.org/TR/css3-animations/#keyframes>
     13
     14        Tests: animations/keyframes-invalid-keys.html
     15               fast/css/webkit-keyframes-errors.html
     16
     17        * css/CSSGrammar.y.in:
     18        * css/CSSParser.cpp:
     19        (WebCore::CSSParser::rewriteSpecifiers):
     20
    1212013-04-25  Antti Koivisto  <antti@apple.com>
    222
  • trunk/Source/WebCore/css/CSSGrammar.y.in

    r147028 r149106  
    877877        else if (str.equalIgnoringCase("to"))
    878878            $$.fValue = 100;
    879         else
     879        else {
     880            $$.unit = 0;
    880881            YYERROR;
     882        }
     883    }
     884    | error {
     885        $$.unit = 0;
    881886    }
    882887    ;
  • trunk/Source/WebCore/css/CSSParser.cpp

    r148949 r149106  
    1179211792    StringBuilder keyString;
    1179311793    for (unsigned i = 0; i < keys->size(); ++i) {
     11794        // Just as per the comment below, we ignore keyframes with
     11795        // invalid key values (plain numbers or unknown identifiers)
     11796        // marked as CSSPrimitiveValue::CSS_UNKNOWN during parsing.
     11797        if (keys->valueAt(i)->unit == CSSPrimitiveValue::CSS_UNKNOWN) {
     11798            clearProperties();
     11799            return 0;
     11800        }
     11801
     11802        ASSERT(keys->valueAt(i)->unit == CSSPrimitiveValue::CSS_NUMBER);
    1179411803        float key = static_cast<float>(keys->valueAt(i)->fValue);
     11804        if (key < 0 || key > 100) {
     11805            // As per http://www.w3.org/TR/css3-animations/#keyframes,
     11806            // "If a keyframe selector specifies negative percentage values
     11807            // or values higher than 100%, then the keyframe will be ignored."
     11808            clearProperties();
     11809            return 0;
     11810        }
    1179511811        if (i != 0)
    1179611812            keyString.append(',');
Note: See TracChangeset for help on using the changeset viewer.