Title: [255028] branches/safari-609-branch/Source/WebCore
Revision
255028
Author
[email protected]
Date
2020-01-23 13:44:34 -0800 (Thu, 23 Jan 2020)

Log Message

Cherry-pick r254800. rdar://problem/58816340

    Make pasteboard markup sanitization more robust
    https://bugs.webkit.org/show_bug.cgi?id=206379
    <rdar://problem/58660859>

    Reviewed by Ryosuke Niwa.

    Makes markup sanitization when copying and pasting more robust in some circumstances (see the bug for additional
    details).

    * editing/markup.cpp:
    (WebCore::createPageForSanitizingWebContent):

    Adopt the new setting when creating the temporary web page used to sanitize markup coming from the pasteboard.

    * html/parser/HTMLParserOptions.cpp:
    (WebCore::HTMLParserOptions::HTMLParserOptions):
    * html/parser/HTMLParserOptions.h:

    Rename `scriptEnabled` to `scriptingFlag`, since parsing script elements may now be allowed even when _javascript_
    execution is disabled. The term "scripting flag" also closely matches the wording of the HTML parsing
    specification.

    * html/parser/HTMLTokenizer.cpp:
    (WebCore::HTMLTokenizer::updateStateFor):
    * html/parser/HTMLTreeBuilder.cpp:
    (WebCore::HTMLTreeBuilder::processStartTagForInBody):
    (WebCore::HTMLTreeBuilder::processStartTagForInHead):
    * page/Settings.yaml:

    Add a new setting to determine whether to consider the scripting flag on when parsing HTML. By default, we will
    only turn the scripting flag on if script execution is enabled; however, this may be set such that we may
    consider the scripting flag set, even though script execution is disabled.

    * page/SettingsBase.h:

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

Modified Paths

Diff

Modified: branches/safari-609-branch/Source/WebCore/ChangeLog (255027 => 255028)


--- branches/safari-609-branch/Source/WebCore/ChangeLog	2020-01-23 21:44:30 UTC (rev 255027)
+++ branches/safari-609-branch/Source/WebCore/ChangeLog	2020-01-23 21:44:34 UTC (rev 255028)
@@ -1,5 +1,83 @@
 2020-01-23  Russell Epstein  <[email protected]>
 
+        Cherry-pick r254800. rdar://problem/58816340
+
+    Make pasteboard markup sanitization more robust
+    https://bugs.webkit.org/show_bug.cgi?id=206379
+    <rdar://problem/58660859>
+    
+    Reviewed by Ryosuke Niwa.
+    
+    Makes markup sanitization when copying and pasting more robust in some circumstances (see the bug for additional
+    details).
+    
+    * editing/markup.cpp:
+    (WebCore::createPageForSanitizingWebContent):
+    
+    Adopt the new setting when creating the temporary web page used to sanitize markup coming from the pasteboard.
+    
+    * html/parser/HTMLParserOptions.cpp:
+    (WebCore::HTMLParserOptions::HTMLParserOptions):
+    * html/parser/HTMLParserOptions.h:
+    
+    Rename `scriptEnabled` to `scriptingFlag`, since parsing script elements may now be allowed even when _javascript_
+    execution is disabled. The term "scripting flag" also closely matches the wording of the HTML parsing
+    specification.
+    
+    * html/parser/HTMLTokenizer.cpp:
+    (WebCore::HTMLTokenizer::updateStateFor):
+    * html/parser/HTMLTreeBuilder.cpp:
+    (WebCore::HTMLTreeBuilder::processStartTagForInBody):
+    (WebCore::HTMLTreeBuilder::processStartTagForInHead):
+    * page/Settings.yaml:
+    
+    Add a new setting to determine whether to consider the scripting flag on when parsing HTML. By default, we will
+    only turn the scripting flag on if script execution is enabled; however, this may be set such that we may
+    consider the scripting flag set, even though script execution is disabled.
+    
+    * page/SettingsBase.h:
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254800 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2020-01-17  Wenson Hsieh  <[email protected]>
+
+            Make pasteboard markup sanitization more robust
+            https://bugs.webkit.org/show_bug.cgi?id=206379
+            <rdar://problem/58660859>
+
+            Reviewed by Ryosuke Niwa.
+
+            Makes markup sanitization when copying and pasting more robust in some circumstances (see the bug for additional
+            details).
+
+            * editing/markup.cpp:
+            (WebCore::createPageForSanitizingWebContent):
+
+            Adopt the new setting when creating the temporary web page used to sanitize markup coming from the pasteboard.
+
+            * html/parser/HTMLParserOptions.cpp:
+            (WebCore::HTMLParserOptions::HTMLParserOptions):
+            * html/parser/HTMLParserOptions.h:
+
+            Rename `scriptEnabled` to `scriptingFlag`, since parsing script elements may now be allowed even when _javascript_
+            execution is disabled. The term "scripting flag" also closely matches the wording of the HTML parsing
+            specification.
+
+            * html/parser/HTMLTokenizer.cpp:
+            (WebCore::HTMLTokenizer::updateStateFor):
+            * html/parser/HTMLTreeBuilder.cpp:
+            (WebCore::HTMLTreeBuilder::processStartTagForInBody):
+            (WebCore::HTMLTreeBuilder::processStartTagForInHead):
+            * page/Settings.yaml:
+
+            Add a new setting to determine whether to consider the scripting flag on when parsing HTML. By default, we will
+            only turn the scripting flag on if script execution is enabled; however, this may be set such that we may
+            consider the scripting flag set, even though script execution is disabled.
+
+            * page/SettingsBase.h:
+
+2020-01-23  Russell Epstein  <[email protected]>
+
         Cherry-pick r254789. rdar://problem/58807968
 
     iOS: Prepare deploying Ref/RefPtr in touch event code

Modified: branches/safari-609-branch/Source/WebCore/editing/markup.cpp (255027 => 255028)


--- branches/safari-609-branch/Source/WebCore/editing/markup.cpp	2020-01-23 21:44:30 UTC (rev 255027)
+++ branches/safari-609-branch/Source/WebCore/editing/markup.cpp	2020-01-23 21:44:34 UTC (rev 255028)
@@ -181,6 +181,7 @@
     auto page = makeUnique<Page>(WTFMove(pageConfiguration));
     page->settings().setMediaEnabled(false);
     page->settings().setScriptEnabled(false);
+    page->settings().setParserScriptingFlagPolicy(SettingsBase::ParserScriptingFlagPolicy::Enabled);
     page->settings().setPluginsEnabled(false);
     page->settings().setAcceleratedCompositingEnabled(false);
 

Modified: branches/safari-609-branch/Source/WebCore/html/parser/HTMLParserOptions.cpp (255027 => 255028)


--- branches/safari-609-branch/Source/WebCore/html/parser/HTMLParserOptions.cpp	2020-01-23 21:44:30 UTC (rev 255027)
+++ branches/safari-609-branch/Source/WebCore/html/parser/HTMLParserOptions.cpp	2020-01-23 21:44:34 UTC (rev 255028)
@@ -36,7 +36,7 @@
 namespace WebCore {
 
 HTMLParserOptions::HTMLParserOptions()
-    : scriptEnabled(false)
+    : scriptingFlag(false)
     , usePreHTML5ParserQuirks(false)
     , maximumDOMTreeDepth(Settings::defaultMaximumHTMLParserDOMTreeDepth)
 {
@@ -45,7 +45,10 @@
 HTMLParserOptions::HTMLParserOptions(Document& document)
 {
     RefPtr<Frame> frame = document.frame();
-    scriptEnabled = frame && frame->script().canExecuteScripts(NotAboutToExecuteScript);
+    if (document.settings().parserScriptingFlagPolicy() == SettingsBase::ParserScriptingFlagPolicy::Enabled)
+        scriptingFlag = true;
+    else
+        scriptingFlag = frame && frame->script().canExecuteScripts(NotAboutToExecuteScript);
 
     usePreHTML5ParserQuirks = document.settings().usePreHTML5ParserQuirks();
     maximumDOMTreeDepth = document.settings().maximumHTMLParserDOMTreeDepth();

Modified: branches/safari-609-branch/Source/WebCore/html/parser/HTMLParserOptions.h (255027 => 255028)


--- branches/safari-609-branch/Source/WebCore/html/parser/HTMLParserOptions.h	2020-01-23 21:44:30 UTC (rev 255027)
+++ branches/safari-609-branch/Source/WebCore/html/parser/HTMLParserOptions.h	2020-01-23 21:44:34 UTC (rev 255028)
@@ -34,7 +34,8 @@
     explicit HTMLParserOptions();
     explicit HTMLParserOptions(Document&);
 
-    bool scriptEnabled;
+    // See https://html.spec.whatwg.org/#scripting-flag for more information.
+    bool scriptingFlag;
     bool usePreHTML5ParserQuirks;
     unsigned maximumDOMTreeDepth;
 };

Modified: branches/safari-609-branch/Source/WebCore/html/parser/HTMLTokenizer.cpp (255027 => 255028)


--- branches/safari-609-branch/Source/WebCore/html/parser/HTMLTokenizer.cpp	2020-01-23 21:44:30 UTC (rev 255027)
+++ branches/safari-609-branch/Source/WebCore/html/parser/HTMLTokenizer.cpp	2020-01-23 21:44:34 UTC (rev 255028)
@@ -1418,7 +1418,7 @@
         || tagName == xmpTag
         || (tagName == noembedTag)
         || tagName == noframesTag
-        || (tagName == noscriptTag && m_options.scriptEnabled))
+        || (tagName == noscriptTag && m_options.scriptingFlag))
         m_state = RAWTEXTState;
 }
 

Modified: branches/safari-609-branch/Source/WebCore/html/parser/HTMLTreeBuilder.cpp (255027 => 255028)


--- branches/safari-609-branch/Source/WebCore/html/parser/HTMLTreeBuilder.cpp	2020-01-23 21:44:30 UTC (rev 255027)
+++ branches/safari-609-branch/Source/WebCore/html/parser/HTMLTreeBuilder.cpp	2020-01-23 21:44:34 UTC (rev 255028)
@@ -791,7 +791,7 @@
         processGenericRawTextStartTag(WTFMove(token));
         return;
     }
-    if (token.name() == noscriptTag && m_options.scriptEnabled) {
+    if (token.name() == noscriptTag && m_options.scriptingFlag) {
         processGenericRawTextStartTag(WTFMove(token));
         return;
     }
@@ -2608,7 +2608,7 @@
         return true;
     }
     if (token.name() == noscriptTag) {
-        if (m_options.scriptEnabled) {
+        if (m_options.scriptingFlag) {
             processGenericRawTextStartTag(WTFMove(token));
             return true;
         }

Modified: branches/safari-609-branch/Source/WebCore/page/Settings.yaml (255027 => 255028)


--- branches/safari-609-branch/Source/WebCore/page/Settings.yaml	2020-01-23 21:44:30 UTC (rev 255027)
+++ branches/safari-609-branch/Source/WebCore/page/Settings.yaml	2020-01-23 21:44:34 UTC (rev 255028)
@@ -728,6 +728,9 @@
   initial: false
   getter: isScriptEnabled
   inspectorOverride: true
+parserScriptingFlagPolicy:
+  type: ParserScriptingFlagPolicy
+  initial: ParserScriptingFlagPolicy::OnlyIfScriptIsEnabled
 pluginsEnabled:
   initial: false
   getter: arePluginsEnabled

Modified: branches/safari-609-branch/Source/WebCore/page/SettingsBase.h (255027 => 255028)


--- branches/safari-609-branch/Source/WebCore/page/SettingsBase.h	2020-01-23 21:44:30 UTC (rev 255027)
+++ branches/safari-609-branch/Source/WebCore/page/SettingsBase.h	2020-01-23 21:44:34 UTC (rev 255028)
@@ -104,6 +104,7 @@
     void pageDestroyed() { m_page = nullptr; }
 
     enum class FontLoadTimingOverride { None, Block, Swap, Failure };
+    enum class ParserScriptingFlagPolicy : uint8_t { OnlyIfScriptIsEnabled, Enabled };
 
     // FIXME: Move these default values to SettingsDefaultValues.h
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to