Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
REGRESSION(r256715): XSLTProcessor does not parse script when transfo…
…rming to document https://bugs.webkit.org/show_bug.cgi?id=226087 Reviewed by Darin Adler. Source/WebCore: Allow JavaScript if context document is null to match old behavior before r256715. Test: fast/xsl/xslt-transform-script.html * dom/Document.cpp: (WebCore::Document::allowsContentJavaScript const): LayoutTests: * fast/xsl/xslt-transform-script.html: Added. * fast/xsl/xslt-transform-script-expected.txt: Added. Canonical link: https://commits.webkit.org/238078@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277951 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
5 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body><a href="javascript:alert(1)">test word</a></body></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<div id="result"></div> | ||
<script> | ||
if (window.testRunner) | ||
testRunner.dumpAsText(); | ||
|
||
var xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><test>test word</test>"; | ||
var xmlParser = new DOMParser(); | ||
var parsedXML = xmlParser.parseFromString(xml, "text/xml"); | ||
|
||
var xsl = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> \ | ||
<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"> \ | ||
<xsl:template match=\"/\"> \ | ||
<html> \ | ||
<body> \ | ||
<a href=\"javascript:alert(1)\"><xsl:value-of select=\"test\"/></a> \ | ||
</body> \ | ||
</html> \ | ||
</xsl:template> \ | ||
</xsl:stylesheet>"; | ||
var xslParser = new DOMParser(); | ||
var parsedXSL = xslParser.parseFromString(xsl, "text/xml"); | ||
|
||
var xslt = new XSLTProcessor(); | ||
xslt.importStylesheet(parsedXSL); | ||
|
||
var transformedXML = xslt.transformToDocument(parsedXML); | ||
var string = new XMLSerializer().serializeToString(transformedXML); | ||
var textNode = document.createTextNode(string); | ||
document.getElementById('result').appendChild(textNode); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters