⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 242851 in webkit


Ignore:
Timestamp:
Mar 13, 2019, 1:24:20 AM (7 years ago)
Author:
bshafiei@apple.com
Message:

Cherry-pick r241608. rdar://problem/48839277

[WebVTT] Inline WebVTT styles should start with '::cue'
https://bugs.webkit.org/show_bug.cgi?id=194227

Reviewed by Eric Carlson.

Source/WebCore:

The original fix in r241203 is not sufficient, since it only checks if the CSS string starts
with '::cue'. Before accepting a CSS string from a WebVTT file, it should be checked that
all selectors starts with '::cue'.

Test: media/track/track-cue-css.html

  • html/track/WebVTTParser.cpp: (WebCore::WebVTTParser::checkAndStoreStyleSheet):

LayoutTests:

Add invalid 'STYLE' blocks which the WebVTT parser should reject.

  • media/track/captions-webvtt/css-styling.vtt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241608 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Location:
branches/safari-607-branch
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-607-branch/LayoutTests/ChangeLog

    r242258 r242851  
     12019-03-13  Babak Shafiei  <bshafiei@apple.com>
     2
     3        Cherry-pick r241608. rdar://problem/48839277
     4
     5    [WebVTT] Inline WebVTT styles should start with '::cue'
     6    https://bugs.webkit.org/show_bug.cgi?id=194227
     7   
     8    Reviewed by Eric Carlson.
     9   
     10    Source/WebCore:
     11   
     12    The original fix in r241203 is not sufficient, since it only checks if the CSS string starts
     13    with '::cue'. Before accepting a CSS string from a WebVTT file, it should be checked that
     14    all selectors starts with '::cue'.
     15   
     16    Test: media/track/track-cue-css.html
     17   
     18    * html/track/WebVTTParser.cpp:
     19    (WebCore::WebVTTParser::checkAndStoreStyleSheet):
     20   
     21    LayoutTests:
     22   
     23    Add invalid 'STYLE' blocks which the WebVTT parser should reject.
     24   
     25    * media/track/captions-webvtt/css-styling.vtt:
     26   
     27   
     28    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241608 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     29
     30    2019-02-15  Per Arne Vollan  <pvollan@apple.com>
     31
     32            [WebVTT] Inline WebVTT styles should start with '::cue'
     33            https://bugs.webkit.org/show_bug.cgi?id=194227
     34
     35            Reviewed by Eric Carlson.
     36
     37            Add invalid 'STYLE' blocks which the WebVTT parser should reject.
     38
     39            * media/track/captions-webvtt/css-styling.vtt:
     40
    1412019-03-01  Babak Shafiei  <bshafiei@apple.com>
    242
  • branches/safari-607-branch/LayoutTests/media/track/captions-webvtt/css-styling.vtt

    r241456 r242851  
    3232}
    3333
     34NOTE the following style block should be discarded since it has a 'video::cue' selector.
     35
     36STYLE
     37::cue {
     38color: blue
     39font-size: 25px;
     40}
     41video::cue {
     42color: blue;
     43font-size: 25px;
     44}
     45
     46NOTE the following style blocks should be discarded since they are invalid in WebVTT files.
     47
     48STYLE
     49::cue,video::cue {
     50color: blue;
     51font-size: 25px;
     52}
     53
     54STYLE
     55color: yellow;
     56
     57NOTE @import and @namespace CSS rules should not be allowed in WebVTT files.
     58NOTE TODO: create a proper testcase for this, see https://bugs.webkit.org/show_bug.cgi?id=194708.
     59
     60STYLE
     61@import url('test.css');
     62
     63STYLE
     64@namespace Foo "test";
     65
     66
    3467hello
    356800:00:00.000 --> 00:00:10.000
  • branches/safari-607-branch/Source/WebCore/ChangeLog

    r242850 r242851  
     12019-03-13  Babak Shafiei  <bshafiei@apple.com>
     2
     3        Cherry-pick r241608. rdar://problem/48839277
     4
     5    [WebVTT] Inline WebVTT styles should start with '::cue'
     6    https://bugs.webkit.org/show_bug.cgi?id=194227
     7   
     8    Reviewed by Eric Carlson.
     9   
     10    Source/WebCore:
     11   
     12    The original fix in r241203 is not sufficient, since it only checks if the CSS string starts
     13    with '::cue'. Before accepting a CSS string from a WebVTT file, it should be checked that
     14    all selectors starts with '::cue'.
     15   
     16    Test: media/track/track-cue-css.html
     17   
     18    * html/track/WebVTTParser.cpp:
     19    (WebCore::WebVTTParser::checkAndStoreStyleSheet):
     20   
     21    LayoutTests:
     22   
     23    Add invalid 'STYLE' blocks which the WebVTT parser should reject.
     24   
     25    * media/track/captions-webvtt/css-styling.vtt:
     26   
     27   
     28    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241608 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     29
     30    2019-02-15  Per Arne Vollan  <pvollan@apple.com>
     31
     32            [WebVTT] Inline WebVTT styles should start with '::cue'
     33            https://bugs.webkit.org/show_bug.cgi?id=194227
     34
     35            Reviewed by Eric Carlson.
     36
     37            The original fix in r241203 is not sufficient, since it only checks if the CSS string starts
     38            with '::cue'. Before accepting a CSS string from a WebVTT file, it should be checked that
     39            all selectors starts with '::cue'.
     40
     41            Test: media/track/track-cue-css.html
     42
     43            * html/track/WebVTTParser.cpp:
     44            (WebCore::WebVTTParser::checkAndStoreStyleSheet):
     45
    1462019-03-13  Babak Shafiei  <bshafiei@apple.com>
    247
  • branches/safari-607-branch/Source/WebCore/html/track/WebVTTParser.cpp

    r241456 r242851  
    4040#include "ISOVTTCue.h"
    4141#include "ProcessingInstruction.h"
     42#include "StyleRule.h"
     43#include "StyleRuleImport.h"
    4244#include "StyleSheetContents.h"
    4345#include "Text.h"
     
    370372        return false;
    371373   
    372     auto styleSheet = m_currentStyleSheet.stripWhiteSpace();
    373    
    374     // Inline VTT styles must start with ::cue.
    375     if (!styleSheet.startsWith("::cue")) {
    376         m_currentStyleSheet = emptyString();
     374    auto styleSheet = WTFMove(m_currentStyleSheet);
     375   
     376    auto contents = StyleSheetContents::create();
     377    if (!contents->parseString(styleSheet))
    377378        return true;
    378     }
    379 
    380     auto contents = StyleSheetContents::create();
    381     if (!contents->parseString(styleSheet)) {
    382         m_currentStyleSheet = emptyString();
     379
     380    auto& namespaceRules = contents->namespaceRules();
     381    if (namespaceRules.size())
    383382        return true;
    384     }
    385    
    386     m_styleSheets.append(WTFMove(m_currentStyleSheet));
     383
     384    auto& importRules = contents->importRules();
     385    if (importRules.size())
     386        return true;
     387
     388    auto& childRules = contents->childRules();
     389    if (!childRules.size())
     390        return true;
     391   
     392    for (auto rule : childRules) {
     393        if (!rule->isStyleRule())
     394            return true;
     395        const auto& styleRule = downcast<StyleRule>(rule.get());
     396
     397        const auto& selectorList = styleRule->selectorList();
     398        if (selectorList.listSize() != 1)
     399            return true;
     400        auto selector = selectorList.selectorAt(0);
     401        if (selector->selectorText() != "::cue")
     402            return true;
     403    }
     404
     405    m_styleSheets.append(styleSheet);
    387406    return true;
    388407}
Note: See TracChangeset for help on using the changeset viewer.