Changeset 286860 in webkit for trunk/Source/WebCore/dom/Element.cpp
- Timestamp:
- Dec 10, 2021, 11:00:44 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/dom/Element.cpp
r286776 r286860 75 75 #include "HTMLOptionElement.h" 76 76 #include "HTMLParserIdioms.h" 77 #include "HTMLScriptElement.h" 77 78 #include "HTMLSelectElement.h" 78 79 #include "HTMLTemplateElement.h" … … 110 111 #include "SVGNames.h" 111 112 #include "SVGSVGElement.h" 113 #include "SVGScriptElement.h" 112 114 #include "ScriptDisallowedScope.h" 113 115 #include "ScrollIntoViewOptions.h" … … 319 321 } 320 322 323 bool Element::isNonceable() const 324 { 325 // https://www.w3.org/TR/CSP3/#is-element-nonceable 326 if (elementRareData()->nonce().isNull()) 327 return false; 328 329 if (hasDuplicateAttribute()) 330 return false; 331 332 if (hasAttributes() 333 && (is<HTMLScriptElement>(*this) || is<SVGScriptElement>(*this))) { 334 static const char scriptString[] = "<script"; 335 static const char styleString[] = "<style"; 336 337 for (const auto& attribute : attributesIterator()) { 338 auto name = attribute.localName().convertToASCIILowercase(); 339 auto value = attribute.value().convertToASCIILowercase(); 340 if (name.contains(scriptString) 341 || name.contains(styleString) 342 || value.contains(scriptString) 343 || value.contains(styleString)) 344 return false; 345 } 346 } 347 348 return true; 349 } 350 321 351 const AtomString& Element::nonce() const 322 352 { 323 return hasRareData() ? elementRareData()->nonce() : emptyAtom(); 353 if (hasRareData() && isNonceable()) 354 return elementRareData()->nonce(); 355 356 return emptyAtom(); 324 357 } 325 358
Note:
See TracChangeset
for help on using the changeset viewer.