Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(247)

Unified Diff: third_party/WebKit/Source/core/svg/SVGScriptElement.cpp

Issue 2644143005: Adjust the <script nonce>-hiding experiment (Closed)
Patch Set: webexposed Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/svg/SVGScriptElement.cpp
diff --git a/third_party/WebKit/Source/core/svg/SVGScriptElement.cpp b/third_party/WebKit/Source/core/svg/SVGScriptElement.cpp
index c0f801a411d0977f340d5889417a038bcf6e6cb0..96455cdd83e3836f3a58f23a22348cf22f22d3e6 100644
--- a/third_party/WebKit/Source/core/svg/SVGScriptElement.cpp
+++ b/third_party/WebKit/Source/core/svg/SVGScriptElement.cpp
@@ -27,6 +27,7 @@
#include "core/dom/ScriptLoader.h"
#include "core/dom/ScriptRunner.h"
#include "core/events/Event.h"
+#include "core/frame/csp/ContentSecurityPolicy.h"
namespace blink {
@@ -36,13 +37,7 @@ inline SVGScriptElement::SVGScriptElement(Document& document,
: SVGElement(SVGNames::scriptTag, document),
SVGURIReference(this),
m_loader(
- ScriptLoader::create(this, wasInsertedByParser, alreadyStarted)) {
- if (fastHasAttribute(HTMLNames::nonceAttr)) {
- m_nonce = fastGetAttribute(HTMLNames::nonceAttr);
- if (RuntimeEnabledFeatures::hideNonceContentAttributeEnabled())
- removeAttribute(HTMLNames::nonceAttr);
- }
-}
+ ScriptLoader::create(this, wasInsertedByParser, alreadyStarted)) {}
SVGScriptElement* SVGScriptElement::create(Document& document,
bool insertedByParser) {
@@ -56,6 +51,14 @@ void SVGScriptElement::parseAttribute(
EventTypeNames::error,
createAttributeEventListener(this, params.name, params.newValue,
eventParameterName()));
+ } else if (params.name == HTMLNames::nonceAttr) {
+ if (params.newValue == ContentSecurityPolicy::getNonceReplacementString())
+ return;
+ setNonce(params.newValue);
+ if (RuntimeEnabledFeatures::hideNonceContentAttributeEnabled()) {
+ setAttribute(HTMLNames::nonceAttr,
+ ContentSecurityPolicy::getNonceReplacementString());
+ }
} else {
SVGElement::parseAttribute(params);
}
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGScriptElement.h ('k') | third_party/WebKit/Source/core/svg/SVGScriptElement.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698