-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cherry-pick c9d2edf. rdar://problem/110134509
[ios] Prioritize text/plain MIME type over file extension for XML file types https://bugs.webkit.org/show_bug.cgi?id=257299 rdar://107379119 Reviewed by David Kilzer. When we receive a file with a text/plain resource, we try harder to find a better match for the file content, but this can potentially lead to an issue with some file types like XML. Therefore, if the server says that a file should be treated as text/plain, and we decide that it is actually XML or SVG, we prefer using text/plain. * LayoutTests/http/tests/mime/resources/.htaccess: Added. * LayoutTests/http/tests/mime/resources/svg-with-html.svg: Added. * LayoutTests/http/tests/mime/resources/xml-with-html.xml: Added. * LayoutTests/http/tests/mime/svg-with-html-expected.txt: Added. * LayoutTests/http/tests/mime/svg-with-html.html: Added. * LayoutTests/http/tests/mime/xml-with-html-expected.txt: Added. * LayoutTests/http/tests/mime/xml-with-html.html: Added. * Source/WebCore/platform/network/ios/WebCoreURLResponseIOS.mm: (WebCore::shouldPreferTextPlainMIMEType): (WebCore::adjustMIMETypeIfNecessary): Canonical link: https://commits.webkit.org/259548.786@safari-7615-branch Identifier: 245886.884@safari-7613.4.1.0-branch
- Loading branch information
Showing
8 changed files
with
72 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<Files xml-with-html.xml> | ||
ForceType "text/plain" | ||
</Files> | ||
<Files svg-with-html.svg> | ||
ForceType "text/plain" | ||
</Files> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,4 @@ | ||
<?xml version=\'1.0\' encoding=\'utf-8\'?> | ||
<html xmlns:html="http://www.w3.org/1999/xhtml"> | ||
<html:script>console.log("Fail");</html:script> | ||
</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,2 @@ | ||
svg-with-html.svg has MIME type text/plain | ||
|
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,24 @@ | ||
<html> | ||
<script> | ||
if (window.testRunner) { | ||
testRunner.waitUntilDone(); | ||
testRunner.dumpResourceResponseMIMETypes(); | ||
testRunner.dumpAsText(); | ||
} | ||
</script> | ||
<body> | ||
<script> | ||
function runTests() { | ||
let iframe = document.createElement("iframe"); | ||
iframe.src = 'resources/svg-with-html.svg'; | ||
if (window.testRunner) { | ||
iframe.onerror = testRunner.notifyDone(); | ||
iframe.onload = testRunner.notifyDone(); | ||
} | ||
document.body.appendChild(iframe); | ||
} | ||
runTests(); | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
xml-with-html.xml has MIME type text/plain | ||
|
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,24 @@ | ||
<html> | ||
<script> | ||
if (window.testRunner) { | ||
testRunner.waitUntilDone(); | ||
testRunner.dumpResourceResponseMIMETypes(); | ||
testRunner.dumpAsText(); | ||
} | ||
</script> | ||
<body> | ||
<script> | ||
function runTests() { | ||
let iframe = document.createElement("iframe"); | ||
iframe.src = 'resources/xml-with-html.xml'; | ||
if (window.testRunner) { | ||
iframe.onerror = testRunner.notifyDone(); | ||
iframe.onload = testRunner.notifyDone(); | ||
} | ||
document.body.appendChild(iframe); | ||
} | ||
runTests(); | ||
</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