Title: [242851] branches/safari-607-branch
Revision
242851
Author
[email protected]
Date
2019-03-13 01:24:20 -0700 (Wed, 13 Mar 2019)

Log 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

Modified Paths

Diff

Modified: branches/safari-607-branch/LayoutTests/ChangeLog (242850 => 242851)


--- branches/safari-607-branch/LayoutTests/ChangeLog	2019-03-13 08:24:17 UTC (rev 242850)
+++ branches/safari-607-branch/LayoutTests/ChangeLog	2019-03-13 08:24:20 UTC (rev 242851)
@@ -1,3 +1,43 @@
+2019-03-13  Babak Shafiei  <[email protected]>
+
+        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
+
+    2019-02-15  Per Arne Vollan  <[email protected]>
+
+            [WebVTT] Inline WebVTT styles should start with '::cue'
+            https://bugs.webkit.org/show_bug.cgi?id=194227
+
+            Reviewed by Eric Carlson.
+
+            Add invalid 'STYLE' blocks which the WebVTT parser should reject.
+
+            * media/track/captions-webvtt/css-styling.vtt:
+
 2019-03-01  Babak Shafiei  <[email protected]>
 
         Cherry-pick r242248. rdar://problem/48503715

Modified: branches/safari-607-branch/LayoutTests/media/track/captions-webvtt/css-styling.vtt (242850 => 242851)


--- branches/safari-607-branch/LayoutTests/media/track/captions-webvtt/css-styling.vtt	2019-03-13 08:24:17 UTC (rev 242850)
+++ branches/safari-607-branch/LayoutTests/media/track/captions-webvtt/css-styling.vtt	2019-03-13 08:24:20 UTC (rev 242851)
@@ -31,6 +31,39 @@
 font-size: 25px;
 }
 
+NOTE the following style block should be discarded since it has a 'video::cue' selector.
+
+STYLE
+::cue {
+color: blue
+font-size: 25px;
+}
+video::cue {
+color: blue;
+font-size: 25px;
+}
+
+NOTE the following style blocks should be discarded since they are invalid in WebVTT files.
+
+STYLE
+::cue,video::cue {
+color: blue;
+font-size: 25px;
+}
+
+STYLE
+color: yellow;
+
+NOTE @import and @namespace CSS rules should not be allowed in WebVTT files.
+NOTE TODO: create a proper testcase for this, see https://bugs.webkit.org/show_bug.cgi?id=194708.
+
+STYLE
+@import url('test.css');
+
+STYLE
+@namespace Foo "test";
+
+
 hello
 00:00:00.000 --> 00:00:10.000
 <b>Hello</b> first cue.

Modified: branches/safari-607-branch/Source/WebCore/ChangeLog (242850 => 242851)


--- branches/safari-607-branch/Source/WebCore/ChangeLog	2019-03-13 08:24:17 UTC (rev 242850)
+++ branches/safari-607-branch/Source/WebCore/ChangeLog	2019-03-13 08:24:20 UTC (rev 242851)
@@ -1,5 +1,50 @@
 2019-03-13  Babak Shafiei  <[email protected]>
 
+        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
+
+    2019-02-15  Per Arne Vollan  <[email protected]>
+
+            [WebVTT] Inline WebVTT styles should start with '::cue'
+            https://bugs.webkit.org/show_bug.cgi?id=194227
+
+            Reviewed by Eric Carlson.
+
+            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):
+
+2019-03-13  Babak Shafiei  <[email protected]>
+
         Cherry-pick r241468. rdar://problem/48839280
 
     REGRESSION: [ Mac Debug WK2 ] Layout Test storage/indexeddb/key-type-infinity-private.html is a flaky crash

Modified: branches/safari-607-branch/Source/WebCore/html/track/WebVTTParser.cpp (242850 => 242851)


--- branches/safari-607-branch/Source/WebCore/html/track/WebVTTParser.cpp	2019-03-13 08:24:17 UTC (rev 242850)
+++ branches/safari-607-branch/Source/WebCore/html/track/WebVTTParser.cpp	2019-03-13 08:24:20 UTC (rev 242851)
@@ -39,6 +39,8 @@
 #include "HTMLParserIdioms.h"
 #include "ISOVTTCue.h"
 #include "ProcessingInstruction.h"
+#include "StyleRule.h"
+#include "StyleRuleImport.h"
 #include "StyleSheetContents.h"
 #include "Text.h"
 #include "VTTScanner.h"
@@ -369,21 +371,38 @@
     if (!line.isEmpty() && !line.contains("-->"))
         return false;
     
-    auto styleSheet = m_currentStyleSheet.stripWhiteSpace();
+    auto styleSheet = WTFMove(m_currentStyleSheet);
     
-    // Inline VTT styles must start with ::cue.
-    if (!styleSheet.startsWith("::cue")) {
-        m_currentStyleSheet = emptyString();
+    auto contents = StyleSheetContents::create();
+    if (!contents->parseString(styleSheet))
         return true;
-    }
 
-    auto contents = StyleSheetContents::create();
-    if (!contents->parseString(styleSheet)) {
-        m_currentStyleSheet = emptyString();
+    auto& namespaceRules = contents->namespaceRules();
+    if (namespaceRules.size())
         return true;
+
+    auto& importRules = contents->importRules();
+    if (importRules.size())
+        return true;
+
+    auto& childRules = contents->childRules();
+    if (!childRules.size())
+        return true;
+    
+    for (auto rule : childRules) {
+        if (!rule->isStyleRule())
+            return true;
+        const auto& styleRule = downcast<StyleRule>(rule.get());
+
+        const auto& selectorList = styleRule->selectorList();
+        if (selectorList.listSize() != 1)
+            return true;
+        auto selector = selectorList.selectorAt(0);
+        if (selector->selectorText() != "::cue")
+            return true;
     }
-    
-    m_styleSheets.append(WTFMove(m_currentStyleSheet));
+
+    m_styleSheets.append(styleSheet);
     return true;
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to