Title: [261443] trunk
Revision
261443
Author
[email protected]
Date
2020-05-09 16:20:29 -0700 (Sat, 09 May 2020)

Log Message

XML external entity resources should only be loaded from XML MIME types
<https://webkit.org/b/211488>
<rdar://problem/62869515>

Reviewed by Darin Adler.

Source/WebCore:

Tests: dom/xhtml/level3/core/entitygetinputencoding03.xhtml
       dom/xhtml/level3/core/entitygetinputencoding04.xhtml
       dom/xhtml/level3/core/entitygetxmlencoding02.xhtml
       dom/xhtml/level3/core/entitygetxmlencoding03.xhtml
       dom/xhtml/level3/core/entitygetxmlencoding04.xhtml
       dom/xhtml/level3/core/entitygetxmlversion03.xhtml
       dom/xhtml/level3/core/entitygetxmlversion04.xhtml
       dom/xhtml/level3/core/nodegetbaseuri16.xhtml
       dom/xhtml/level3/core/nodegetbaseuri19.xhtml
       dom/xhtml/level3/core/nodegetbaseuri20.xhtml
       fast/parser/external-entities-in-xslt.xml
       fast/xsl/dtd-in-source-document.xml
       fast/xsl/xslt-second-level-import.xml
       http/tests/security/contentTypeOptions/nosniff-xml-external-entity.xhtml
       http/tests/security/xss-DENIED-xsl-external-entity-redirect.xml

* html/HTMLBaseElement.cpp:
(WebCore::HTMLBaseElement::href const):
- Add comment about keeping code in sync with openFunc() in
  XMLDocumentParserLibxml2.cpp.
* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::responseMIMEType const):
- Add comment about keeping code in sync with
  externalEntityMimeTypeAllowed() in
  XMLDocumentParserLibxml2.cpp.
* xml/parser/XMLDocumentParserLibxml2.cpp:
(WebCore::externalEntityMimeTypeAllowed):
- Rename from externalEntityMimeTypeAllowedByNosniff().
- Change to only allow XML MIME types regardless of nosniff
  option.
- Add fallback path to determine MIME type for file:/// URLs to
  make layout tests work properly.  Logic taken from
  XMLHttpRequest::responseMIMEType().  Not sure if there was a
  good place to share it.
(WebCore::openFunc):
- Fix relative URLs by providing the document's URL as a base.
  Also provide an encoding if needed.  Logic taken from
  HTMLBaseElement::href().  (Not sure if there was a good place
  to share it.)  This was required to fix loading of external
  entity resources in the dom/xhtml/level3/core tests, which
  hadn't been loading these resources for a while.  Ultimately
  this didn't matter--except for new error messages being
  printed in test results--because the tests fail due to missing
  DOM features for XHTML documents).
- Change the fix for Bug 21963 into an empty URL check since
  setting FetchOptions.mode to Mode::SameOrigin prevents a
  redirect from loading a resource outside the document's
  origin.  The previous check worked, but the relaxed check in
  externalEntityMimeTypeAllowed() caused the XML MIME type
  warning to be output on redirects to non-same-origin URLs.  I
  didn't see a way to check for a cross-origin loading error.
- Add a console message for a cross-origin load failing.
- Update for function rename.
- Remove double negative from console message for an invalid
  MIME type.
(WebCore::externalEntityMimeTypeAllowedByNosniff):
- Rename to externalEntityMimeTypeAllowed().

LayoutTests:

To fix these layout tests, the following changes were made:
- Rename *.ent files to *.ent.xml so that an XML MIME type would
  be given to the resources when loading from a file:/// URL.
- Similarly, rename *.dtd files to *.dtd.xml.
- Update tests to refer to new entity/dtd file names.
- There are more *.dtd and *.ent files that weren't renamed.  I
  will fix those in a follow-up patch.  They weren't needed to
  fix any tests, so may be unused.

* dom/xhtml/level3/core/entitygetinputencoding03.xhtml:
* dom/xhtml/level3/core/entitygetinputencoding04.xhtml:
* dom/xhtml/level3/core/entitygetxmlencoding02.xhtml:
* dom/xhtml/level3/core/entitygetxmlencoding03.xhtml:
* dom/xhtml/level3/core/entitygetxmlencoding04.xhtml:
* dom/xhtml/level3/core/entitygetxmlversion03.xhtml:
* dom/xhtml/level3/core/entitygetxmlversion04.xhtml:
* dom/xhtml/level3/core/resources/external_foo.ent.xml: Rename from LayoutTests/dom/xhtml/level3/core/external_foo.ent.xml.
* dom/xhtml/level3/core/resources/external_foobr.ent.xml: Rename from LayoutTests/dom/xhtml/level3/core/external_foobr.ent.xml.
* dom/xhtml/level3/core/resources/external_widget.ent.xml: Rename from LayoutTests/dom/xhtml/level3/core/external_widget.ent.xml.
* dom/xhtml/level3/core/nodegetbaseuri16.xhtml:
* dom/xhtml/level3/core/nodegetbaseuri19.xhtml:
* dom/xhtml/level3/core/nodegetbaseuri20.xhtml:
* fast/parser/external-entities.xml:
* fast/parser/resources/external-entities.dtd.xml: Rename from LayoutTests/fast/parser/resources/external-entities.dtd.
* fast/parser/resources/external-entities.xsl:
* fast/xsl/dtd-in-source-document.xml:
* fast/xsl/resources/dtd-in-source-document.dtd.xml: Rename from LayoutTests/fast/xsl/resources/dtd-in-source-document.dtd.
* fast/xsl/resources/xslt-second-level-import.xsl:
* fast/xsl/resources/xslt-second-level-import.xsl.dtd.xml: Rename from LayoutTests/fast/xsl/resources/xslt-second-level-import.xsl.dtd.

* http/tests/security/contentTypeOptions/nosniff-xml-external-entity-expected.txt:
* http/tests/security/contentTypeOptions/nosniff-xml-external-entity.xhtml:
- Add test cases without "X-Content-Type-Options: nosniff"
  header.

* http/tests/security/xss-DENIED-xsl-external-entity-redirect-expected.txt:
- Add newly expected console error messages about cross-origin
  resource load failures.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (261442 => 261443)


--- trunk/LayoutTests/ChangeLog	2020-05-09 23:10:41 UTC (rev 261442)
+++ trunk/LayoutTests/ChangeLog	2020-05-09 23:20:29 UTC (rev 261443)
@@ -1,3 +1,50 @@
+2020-05-09  David Kilzer  <[email protected]>
+
+        XML external entity resources should only be loaded from XML MIME types
+        <https://webkit.org/b/211488>
+        <rdar://problem/62869515>
+
+        Reviewed by Darin Adler.
+
+        To fix these layout tests, the following changes were made:
+        - Rename *.ent files to *.ent.xml so that an XML MIME type would
+          be given to the resources when loading from a file:/// URL.
+        - Similarly, rename *.dtd files to *.dtd.xml.
+        - Update tests to refer to new entity/dtd file names.
+        - There are more *.dtd and *.ent files that weren't renamed.  I
+          will fix those in a follow-up patch.  They weren't needed to
+          fix any tests, so may be unused.
+
+        * dom/xhtml/level3/core/entitygetinputencoding03.xhtml:
+        * dom/xhtml/level3/core/entitygetinputencoding04.xhtml:
+        * dom/xhtml/level3/core/entitygetxmlencoding02.xhtml:
+        * dom/xhtml/level3/core/entitygetxmlencoding03.xhtml:
+        * dom/xhtml/level3/core/entitygetxmlencoding04.xhtml:
+        * dom/xhtml/level3/core/entitygetxmlversion03.xhtml:
+        * dom/xhtml/level3/core/entitygetxmlversion04.xhtml:
+        * dom/xhtml/level3/core/resources/external_foo.ent.xml: Rename from LayoutTests/dom/xhtml/level3/core/external_foo.ent.xml.
+        * dom/xhtml/level3/core/resources/external_foobr.ent.xml: Rename from LayoutTests/dom/xhtml/level3/core/external_foobr.ent.xml.
+        * dom/xhtml/level3/core/resources/external_widget.ent.xml: Rename from LayoutTests/dom/xhtml/level3/core/external_widget.ent.xml.
+        * dom/xhtml/level3/core/nodegetbaseuri16.xhtml:
+        * dom/xhtml/level3/core/nodegetbaseuri19.xhtml:
+        * dom/xhtml/level3/core/nodegetbaseuri20.xhtml:
+        * fast/parser/external-entities.xml:
+        * fast/parser/resources/external-entities.dtd.xml: Rename from LayoutTests/fast/parser/resources/external-entities.dtd.
+        * fast/parser/resources/external-entities.xsl:
+        * fast/xsl/dtd-in-source-document.xml:
+        * fast/xsl/resources/dtd-in-source-document.dtd.xml: Rename from LayoutTests/fast/xsl/resources/dtd-in-source-document.dtd.
+        * fast/xsl/resources/xslt-second-level-import.xsl:
+        * fast/xsl/resources/xslt-second-level-import.xsl.dtd.xml: Rename from LayoutTests/fast/xsl/resources/xslt-second-level-import.xsl.dtd.
+
+        * http/tests/security/contentTypeOptions/nosniff-xml-external-entity-expected.txt:
+        * http/tests/security/contentTypeOptions/nosniff-xml-external-entity.xhtml:
+        - Add test cases without "X-Content-Type-Options: nosniff"
+          header.
+
+        * http/tests/security/xss-DENIED-xsl-external-entity-redirect-expected.txt:
+        - Add newly expected console error messages about cross-origin
+          resource load failures.
+
 2020-05-09  Diego Pino Garcia  <[email protected]>
 
         [GTK] Gardening, update test expectations

Modified: trunk/LayoutTests/dom/xhtml/level3/core/entitygetinputencoding03.xhtml (261442 => 261443)


--- trunk/LayoutTests/dom/xhtml/level3/core/entitygetinputencoding03.xhtml	2020-05-09 23:10:41 UTC (rev 261442)
+++ trunk/LayoutTests/dom/xhtml/level3/core/entitygetinputencoding03.xhtml	2020-05-09 23:20:29 UTC (rev 261443)
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE html [
-<!ENTITY ent1 SYSTEM 'external_foo.ent'>
-<!ENTITY ent2 SYSTEM 'external_foobr.ent'>
-<!ENTITY ent3 SYSTEM 'external_widget.ent'>
+<!ENTITY ent1 SYSTEM 'resources/external_foo.ent.xml'>
+<!ENTITY ent2 SYSTEM 'resources/external_foobr.ent.xml'>
+<!ENTITY ent3 SYSTEM 'resources/external_widget.ent.xml'>
 <!ENTITY ent5 PUBLIC "entityURI" "entityFile" NDATA notation1>
 <!ELEMENT html (head, body)>
 <!ATTLIST html xmlns CDATA #IMPLIED>

Modified: trunk/LayoutTests/dom/xhtml/level3/core/entitygetinputencoding04.xhtml (261442 => 261443)


--- trunk/LayoutTests/dom/xhtml/level3/core/entitygetinputencoding04.xhtml	2020-05-09 23:10:41 UTC (rev 261442)
+++ trunk/LayoutTests/dom/xhtml/level3/core/entitygetinputencoding04.xhtml	2020-05-09 23:20:29 UTC (rev 261443)
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE html [
-<!ENTITY ent1 SYSTEM 'external_foo.ent'>
-<!ENTITY ent2 SYSTEM 'external_foobr.ent'>
-<!ENTITY ent3 SYSTEM 'external_widget.ent'>
+<!ENTITY ent1 SYSTEM 'resources/external_foo.ent.xml'>
+<!ENTITY ent2 SYSTEM 'resources/external_foobr.ent.xml'>
+<!ENTITY ent3 SYSTEM 'resources/external_widget.ent.xml'>
 <!ENTITY ent5 PUBLIC "entityURI" "entityFile" NDATA notation1>
 <!ELEMENT html (head, body)>
 <!ATTLIST html xmlns CDATA #IMPLIED>

Modified: trunk/LayoutTests/dom/xhtml/level3/core/entitygetxmlencoding02.xhtml (261442 => 261443)


--- trunk/LayoutTests/dom/xhtml/level3/core/entitygetxmlencoding02.xhtml	2020-05-09 23:10:41 UTC (rev 261442)
+++ trunk/LayoutTests/dom/xhtml/level3/core/entitygetxmlencoding02.xhtml	2020-05-09 23:20:29 UTC (rev 261443)
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE html [
-<!ENTITY ent1 SYSTEM 'external_foo.ent'>
-<!ENTITY ent2 SYSTEM 'external_foobr.ent'>
-<!ENTITY ent3 SYSTEM 'external_widget.ent'>
+<!ENTITY ent1 SYSTEM 'resources/external_foo.ent.xml'>
+<!ENTITY ent2 SYSTEM 'resources/external_foobr.ent.xml'>
+<!ENTITY ent3 SYSTEM 'resources/external_widget.ent.xml'>
 <!ENTITY ent5 PUBLIC "entityURI" "entityFile" NDATA notation1>
 <!ELEMENT html (head, body)>
 <!ATTLIST html xmlns CDATA #IMPLIED>

Modified: trunk/LayoutTests/dom/xhtml/level3/core/entitygetxmlencoding03.xhtml (261442 => 261443)


--- trunk/LayoutTests/dom/xhtml/level3/core/entitygetxmlencoding03.xhtml	2020-05-09 23:10:41 UTC (rev 261442)
+++ trunk/LayoutTests/dom/xhtml/level3/core/entitygetxmlencoding03.xhtml	2020-05-09 23:20:29 UTC (rev 261443)
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE html [
-<!ENTITY ent1 SYSTEM 'external_foo.ent'>
-<!ENTITY ent2 SYSTEM 'external_foobr.ent'>
-<!ENTITY ent3 SYSTEM 'external_widget.ent'>
+<!ENTITY ent1 SYSTEM 'resources/external_foo.ent.xml'>
+<!ENTITY ent2 SYSTEM 'resources/external_foobr.ent.xml'>
+<!ENTITY ent3 SYSTEM 'resources/external_widget.ent.xml'>
 <!ENTITY ent5 PUBLIC "entityURI" "entityFile" NDATA notation1>
 <!ELEMENT html (head, body)>
 <!ATTLIST html xmlns CDATA #IMPLIED>

Modified: trunk/LayoutTests/dom/xhtml/level3/core/entitygetxmlencoding04.xhtml (261442 => 261443)


--- trunk/LayoutTests/dom/xhtml/level3/core/entitygetxmlencoding04.xhtml	2020-05-09 23:10:41 UTC (rev 261442)
+++ trunk/LayoutTests/dom/xhtml/level3/core/entitygetxmlencoding04.xhtml	2020-05-09 23:20:29 UTC (rev 261443)
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE html [
-<!ENTITY ent1 SYSTEM 'external_foo.ent'>
-<!ENTITY ent2 SYSTEM 'external_foobr.ent'>
-<!ENTITY ent3 SYSTEM 'external_widget.ent'>
+<!ENTITY ent1 SYSTEM 'resources/external_foo.ent.xml'>
+<!ENTITY ent2 SYSTEM 'resources/external_foobr.ent.xml'>
+<!ENTITY ent3 SYSTEM 'resources/external_widget.ent.xml'>
 <!ENTITY ent5 PUBLIC "entityURI" "entityFile" NDATA notation1>
 <!ELEMENT html (head, body)>
 <!ATTLIST html xmlns CDATA #IMPLIED>

Modified: trunk/LayoutTests/dom/xhtml/level3/core/entitygetxmlversion03.xhtml (261442 => 261443)


--- trunk/LayoutTests/dom/xhtml/level3/core/entitygetxmlversion03.xhtml	2020-05-09 23:10:41 UTC (rev 261442)
+++ trunk/LayoutTests/dom/xhtml/level3/core/entitygetxmlversion03.xhtml	2020-05-09 23:20:29 UTC (rev 261443)
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE html [
-<!ENTITY ent1 SYSTEM 'external_foo.ent'>
-<!ENTITY ent2 SYSTEM 'external_foobr.ent'>
-<!ENTITY ent3 SYSTEM 'external_widget.ent'>
+<!ENTITY ent1 SYSTEM 'resources/external_foo.ent.xml'>
+<!ENTITY ent2 SYSTEM 'resources/external_foobr.ent.xml'>
+<!ENTITY ent3 SYSTEM 'resources/external_widget.ent.xml'>
 <!ENTITY ent5 PUBLIC "entityURI" "entityFile" NDATA notation1>
 <!ELEMENT html (head, body)>
 <!ATTLIST html xmlns CDATA #IMPLIED>

Modified: trunk/LayoutTests/dom/xhtml/level3/core/entitygetxmlversion04.xhtml (261442 => 261443)


--- trunk/LayoutTests/dom/xhtml/level3/core/entitygetxmlversion04.xhtml	2020-05-09 23:10:41 UTC (rev 261442)
+++ trunk/LayoutTests/dom/xhtml/level3/core/entitygetxmlversion04.xhtml	2020-05-09 23:20:29 UTC (rev 261443)
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE html [
-<!ENTITY ent1 SYSTEM 'external_foo.ent'>
-<!ENTITY ent2 SYSTEM 'external_foobr.ent'>
-<!ENTITY ent3 SYSTEM 'external_widget.ent'>
+<!ENTITY ent1 SYSTEM 'resources/external_foo.ent.xml'>
+<!ENTITY ent2 SYSTEM 'resources/external_foobr.ent.xml'>
+<!ENTITY ent3 SYSTEM 'resources/external_widget.ent.xml'>
 <!ENTITY ent5 PUBLIC "entityURI" "entityFile" NDATA notation1>
 <!ELEMENT html (head, body)>
 <!ATTLIST html xmlns CDATA #IMPLIED>

Deleted: trunk/LayoutTests/dom/xhtml/level3/core/external_foo.ent (261442 => 261443)


--- trunk/LayoutTests/dom/xhtml/level3/core/external_foo.ent	2020-05-09 23:10:41 UTC (rev 261442)
+++ trunk/LayoutTests/dom/xhtml/level3/core/external_foo.ent	2020-05-09 23:20:29 UTC (rev 261443)
@@ -1 +0,0 @@
-\xFF\xFE<��?��x��m��l�� ��v��e��r��s��i��o��n��=��"��1��.��0��"�� ��e��n��c��o��d��i��n��g��=��"��u��T��f��-��1��6��"��?��>��f��o��o��
\ No newline at end of file

Deleted: trunk/LayoutTests/dom/xhtml/level3/core/external_foobr.ent (261442 => 261443)


--- trunk/LayoutTests/dom/xhtml/level3/core/external_foobr.ent	2020-05-09 23:10:41 UTC (rev 261442)
+++ trunk/LayoutTests/dom/xhtml/level3/core/external_foobr.ent	2020-05-09 23:20:29 UTC (rev 261443)
@@ -1 +0,0 @@
-<br/>foo
\ No newline at end of file

Deleted: trunk/LayoutTests/dom/xhtml/level3/core/external_widget.ent (261442 => 261443)


--- trunk/LayoutTests/dom/xhtml/level3/core/external_widget.ent	2020-05-09 23:10:41 UTC (rev 261442)
+++ trunk/LayoutTests/dom/xhtml/level3/core/external_widget.ent	2020-05-09 23:20:29 UTC (rev 261443)
@@ -1 +0,0 @@
-<p xmlns='http://www.w3.org/1999/xhtml'>widget</p>

Modified: trunk/LayoutTests/dom/xhtml/level3/core/nodegetbaseuri16.xhtml (261442 => 261443)


--- trunk/LayoutTests/dom/xhtml/level3/core/nodegetbaseuri16.xhtml	2020-05-09 23:10:41 UTC (rev 261442)
+++ trunk/LayoutTests/dom/xhtml/level3/core/nodegetbaseuri16.xhtml	2020-05-09 23:20:29 UTC (rev 261443)
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE html [
-<!ENTITY ent1 SYSTEM 'external_foo.ent'>
-<!ENTITY ent2 SYSTEM 'external_foobr.ent'>
-<!ENTITY ent3 SYSTEM 'external_widget.ent'>
+<!ENTITY ent1 SYSTEM 'resources/external_foo.ent.xml'>
+<!ENTITY ent2 SYSTEM 'resources/external_foobr.ent.xml'>
+<!ENTITY ent3 SYSTEM 'resources/external_widget.ent.xml'>
 <!ENTITY ent5 PUBLIC "entityURI" "entityFile" NDATA notation1>
 <!ELEMENT html (head, body)>
 <!ATTLIST html xmlns CDATA #IMPLIED>

Modified: trunk/LayoutTests/dom/xhtml/level3/core/nodegetbaseuri19.xhtml (261442 => 261443)


--- trunk/LayoutTests/dom/xhtml/level3/core/nodegetbaseuri19.xhtml	2020-05-09 23:10:41 UTC (rev 261442)
+++ trunk/LayoutTests/dom/xhtml/level3/core/nodegetbaseuri19.xhtml	2020-05-09 23:20:29 UTC (rev 261443)
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE html [
-<!ENTITY ent1 SYSTEM 'external_foo.ent'>
-<!ENTITY ent2 SYSTEM 'external_foobr.ent'>
-<!ENTITY ent3 SYSTEM 'external_widget.ent'>
+<!ENTITY ent1 SYSTEM 'resources/external_foo.ent.xml'>
+<!ENTITY ent2 SYSTEM 'resources/external_foobr.ent.xml'>
+<!ENTITY ent3 SYSTEM 'resources/external_widget.ent.xml'>
 <!ENTITY ent5 PUBLIC "entityURI" "entityFile" NDATA notation1>
 <!ELEMENT html (head, body)>
 <!ATTLIST html xmlns CDATA #IMPLIED>

Modified: trunk/LayoutTests/dom/xhtml/level3/core/nodegetbaseuri20.xhtml (261442 => 261443)


--- trunk/LayoutTests/dom/xhtml/level3/core/nodegetbaseuri20.xhtml	2020-05-09 23:10:41 UTC (rev 261442)
+++ trunk/LayoutTests/dom/xhtml/level3/core/nodegetbaseuri20.xhtml	2020-05-09 23:20:29 UTC (rev 261443)
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE html [
-<!ENTITY ent1 SYSTEM 'external_foo.ent'>
-<!ENTITY ent2 SYSTEM 'external_foobr.ent'>
-<!ENTITY ent3 SYSTEM 'external_widget.ent'>
+<!ENTITY ent1 SYSTEM 'resources/external_foo.ent.xml'>
+<!ENTITY ent2 SYSTEM 'resources/external_foobr.ent.xml'>
+<!ENTITY ent3 SYSTEM 'resources/external_widget.ent.xml'>
 <!ENTITY ent5 PUBLIC "entityURI" "entityFile" NDATA notation1>
 <!ELEMENT html (head, body)>
 <!ATTLIST html xmlns CDATA #IMPLIED>

Copied: trunk/LayoutTests/dom/xhtml/level3/core/resources/external_foo.ent.xml (from rev 261442, trunk/LayoutTests/dom/xhtml/level3/core/external_foo.ent) (0 => 261443)


--- trunk/LayoutTests/dom/xhtml/level3/core/resources/external_foo.ent.xml	                        (rev 0)
+++ trunk/LayoutTests/dom/xhtml/level3/core/resources/external_foo.ent.xml	2020-05-09 23:20:29 UTC (rev 261443)
@@ -0,0 +1 @@
+\xFF\xFE<��?��x��m��l�� ��v��e��r��s��i��o��n��=��"��1��.��0��"�� ��e��n��c��o��d��i��n��g��=��"��u��T��f��-��1��6��"��?��>��f��o��o��
\ No newline at end of file

Copied: trunk/LayoutTests/dom/xhtml/level3/core/resources/external_foobr.ent.xml (from rev 261442, trunk/LayoutTests/dom/xhtml/level3/core/external_foobr.ent) (0 => 261443)


--- trunk/LayoutTests/dom/xhtml/level3/core/resources/external_foobr.ent.xml	                        (rev 0)
+++ trunk/LayoutTests/dom/xhtml/level3/core/resources/external_foobr.ent.xml	2020-05-09 23:20:29 UTC (rev 261443)
@@ -0,0 +1 @@
+<br/>foo
\ No newline at end of file

Copied: trunk/LayoutTests/dom/xhtml/level3/core/resources/external_widget.ent.xml (from rev 261442, trunk/LayoutTests/dom/xhtml/level3/core/external_widget.ent) (0 => 261443)


--- trunk/LayoutTests/dom/xhtml/level3/core/resources/external_widget.ent.xml	                        (rev 0)
+++ trunk/LayoutTests/dom/xhtml/level3/core/resources/external_widget.ent.xml	2020-05-09 23:20:29 UTC (rev 261443)
@@ -0,0 +1 @@
+<p xmlns='http://www.w3.org/1999/xhtml'>widget</p>

Modified: trunk/LayoutTests/fast/parser/external-entities.xml (261442 => 261443)


--- trunk/LayoutTests/fast/parser/external-entities.xml	2020-05-09 23:10:41 UTC (rev 261442)
+++ trunk/LayoutTests/fast/parser/external-entities.xml	2020-05-09 23:20:29 UTC (rev 261443)
@@ -1,5 +1,5 @@
 <?xml version="1.0" ?>
-<!DOCTYPE html SYSTEM "resources/external-entities.dtd">
+<!DOCTYPE html SYSTEM "resources/external-entities.dtd.xml">
 <html xmlns="http://www.w3.org/1999/xhtml">
 <body>
 <script type="text/_javascript_">

Deleted: trunk/LayoutTests/fast/parser/resources/external-entities.dtd (261442 => 261443)


--- trunk/LayoutTests/fast/parser/resources/external-entities.dtd	2020-05-09 23:10:41 UTC (rev 261442)
+++ trunk/LayoutTests/fast/parser/resources/external-entities.dtd	2020-05-09 23:20:29 UTC (rev 261443)
@@ -1 +0,0 @@
-<!ENTITY message "SUCCESS">
\ No newline at end of file

Copied: trunk/LayoutTests/fast/parser/resources/external-entities.dtd.xml (from rev 261442, trunk/LayoutTests/fast/parser/resources/external-entities.dtd) (0 => 261443)


--- trunk/LayoutTests/fast/parser/resources/external-entities.dtd.xml	                        (rev 0)
+++ trunk/LayoutTests/fast/parser/resources/external-entities.dtd.xml	2020-05-09 23:20:29 UTC (rev 261443)
@@ -0,0 +1 @@
+<!ENTITY message "SUCCESS">
\ No newline at end of file

Modified: trunk/LayoutTests/fast/parser/resources/external-entities.xsl (261442 => 261443)


--- trunk/LayoutTests/fast/parser/resources/external-entities.xsl	2020-05-09 23:10:41 UTC (rev 261442)
+++ trunk/LayoutTests/fast/parser/resources/external-entities.xsl	2020-05-09 23:20:29 UTC (rev 261443)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8" ?>
-<!DOCTYPE xsl:stylesheet SYSTEM "external-entities.dtd">
+<!DOCTYPE xsl:stylesheet SYSTEM "external-entities.dtd.xml">
 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:template match="/">
         <HTML>
@@ -12,4 +12,4 @@
             </BODY>
         </HTML>
     </xsl:template>
-</xsl:stylesheet>
\ No newline at end of file
+</xsl:stylesheet>

Modified: trunk/LayoutTests/fast/xsl/dtd-in-source-document.xml (261442 => 261443)


--- trunk/LayoutTests/fast/xsl/dtd-in-source-document.xml	2020-05-09 23:10:41 UTC (rev 261442)
+++ trunk/LayoutTests/fast/xsl/dtd-in-source-document.xml	2020-05-09 23:20:29 UTC (rev 261443)
@@ -1,4 +1,4 @@
 <?xml version="1.0"?>
-<!DOCTYPE xml SYSTEM "resources/dtd-in-source-document.dtd">
+<!DOCTYPE xml SYSTEM "resources/dtd-in-source-document.dtd.xml">
 <?xml-stylesheet type="text/xsl" href=""
 <TEST>&Result;</TEST>

Deleted: trunk/LayoutTests/fast/xsl/resources/dtd-in-source-document.dtd (261442 => 261443)


--- trunk/LayoutTests/fast/xsl/resources/dtd-in-source-document.dtd	2020-05-09 23:10:41 UTC (rev 261442)
+++ trunk/LayoutTests/fast/xsl/resources/dtd-in-source-document.dtd	2020-05-09 23:20:29 UTC (rev 261443)
@@ -1 +0,0 @@
-<!ENTITY Result "SUCCESS">

Copied: trunk/LayoutTests/fast/xsl/resources/dtd-in-source-document.dtd.xml (from rev 261442, trunk/LayoutTests/fast/xsl/resources/dtd-in-source-document.dtd) (0 => 261443)


--- trunk/LayoutTests/fast/xsl/resources/dtd-in-source-document.dtd.xml	                        (rev 0)
+++ trunk/LayoutTests/fast/xsl/resources/dtd-in-source-document.dtd.xml	2020-05-09 23:20:29 UTC (rev 261443)
@@ -0,0 +1 @@
+<!ENTITY Result "SUCCESS">

Modified: trunk/LayoutTests/fast/xsl/resources/xslt-second-level-import.xsl (261442 => 261443)


--- trunk/LayoutTests/fast/xsl/resources/xslt-second-level-import.xsl	2020-05-09 23:10:41 UTC (rev 261442)
+++ trunk/LayoutTests/fast/xsl/resources/xslt-second-level-import.xsl	2020-05-09 23:20:29 UTC (rev 261443)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE xsl:stylesheet SYSTEM "xslt-second-level-import.xsl.dtd">
+<!DOCTYPE xsl:stylesheet SYSTEM "xslt-second-level-import.xsl.dtd.xml">
 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   <xsl:include href="" />
   <xsl:template match="/">

Deleted: trunk/LayoutTests/fast/xsl/resources/xslt-second-level-import.xsl.dtd (261442 => 261443)


--- trunk/LayoutTests/fast/xsl/resources/xslt-second-level-import.xsl.dtd	2020-05-09 23:10:41 UTC (rev 261442)
+++ trunk/LayoutTests/fast/xsl/resources/xslt-second-level-import.xsl.dtd	2020-05-09 23:20:29 UTC (rev 261443)
@@ -1 +0,0 @@
-<!ENTITY success "SUCCESS">

Copied: trunk/LayoutTests/fast/xsl/resources/xslt-second-level-import.xsl.dtd.xml (from rev 261442, trunk/LayoutTests/fast/xsl/resources/xslt-second-level-import.xsl.dtd) (0 => 261443)


--- trunk/LayoutTests/fast/xsl/resources/xslt-second-level-import.xsl.dtd.xml	                        (rev 0)
+++ trunk/LayoutTests/fast/xsl/resources/xslt-second-level-import.xsl.dtd.xml	2020-05-09 23:20:29 UTC (rev 261443)
@@ -0,0 +1 @@
+<!ENTITY success "SUCCESS">

Modified: trunk/LayoutTests/http/tests/security/contentTypeOptions/nosniff-xml-external-entity-expected.txt (261442 => 261443)


--- trunk/LayoutTests/http/tests/security/contentTypeOptions/nosniff-xml-external-entity-expected.txt	2020-05-09 23:10:41 UTC (rev 261442)
+++ trunk/LayoutTests/http/tests/security/contentTypeOptions/nosniff-xml-external-entity-expected.txt	2020-05-09 23:20:29 UTC (rev 261443)
@@ -1,16 +1,23 @@
-CONSOLE MESSAGE: Did not parse external entity resource at 'http://127.0.0.1:8000/security/contentTypeOptions/resources/script-with-header.pl?mime=application/pdf' because non XML External Entity MIME types are not allowed when 'X-Content-Type-Options: nosniff' is given.
-CONSOLE MESSAGE: Did not parse external entity resource at 'http://127.0.0.1:8000/security/contentTypeOptions/resources/script-with-header.pl?mime=text/html' because non XML External Entity MIME types are not allowed when 'X-Content-Type-Options: nosniff' is given.
-CONSOLE MESSAGE: Did not parse external entity resource at 'http://127.0.0.1:8000/security/contentTypeOptions/resources/script-with-header.pl?mime=text/_javascript_' because non XML External Entity MIME types are not allowed when 'X-Content-Type-Options: nosniff' is given.
+CONSOLE MESSAGE: Did not parse external entity resource at 'http://127.0.0.1:8000/security/contentTypeOptions/resources/script-with-header.pl?mime=application/pdf' because only XML MIME types are allowed.
+CONSOLE MESSAGE: Did not parse external entity resource at 'http://127.0.0.1:8000/security/contentTypeOptions/resources/script-with-header.pl?mime=text/html' because only XML MIME types are allowed.
+CONSOLE MESSAGE: Did not parse external entity resource at 'http://127.0.0.1:8000/security/contentTypeOptions/resources/script-with-header.pl?mime=text/_javascript_' because only XML MIME types are allowed.
+CONSOLE MESSAGE: Did not parse external entity resource at 'http://127.0.0.1:8000/security/contentTypeOptions/resources/script-with-header.pl?no-content-type-options=1&mime=application/pdf' because only XML MIME types are allowed.
+CONSOLE MESSAGE: Did not parse external entity resource at 'http://127.0.0.1:8000/security/contentTypeOptions/resources/script-with-header.pl?no-content-type-options=1&mime=text/html' because only XML MIME types are allowed.
+CONSOLE MESSAGE: Did not parse external entity resource at 'http://127.0.0.1:8000/security/contentTypeOptions/resources/script-with-header.pl?no-content-type-options=1&mime=text/_javascript_' because only XML MIME types are allowed.
 CONSOLE MESSAGE: Executed script with MIME type: 'application/xml'.
 CONSOLE MESSAGE: Executed script with MIME type: 'text/xml'.
 CONSOLE MESSAGE: Executed script with MIME type: 'application/xml-external-parsed-entity'.
 CONSOLE MESSAGE: Executed script with MIME type: 'text/xml-external-parsed-entity'.
-Check that xml external entity resources loaded with an 'X-Content-Type-Options: nosniff' header are correctly accepted or blocked based on the MIME type.
+CONSOLE MESSAGE: Executed script with MIME type: 'application/xml'.
+CONSOLE MESSAGE: Executed script with MIME type: 'text/xml'.
+CONSOLE MESSAGE: Executed script with MIME type: 'application/xml-external-parsed-entity'.
+CONSOLE MESSAGE: Executed script with MIME type: 'text/xml-external-parsed-entity'.
+Check that xml external entity resources loaded are correctly accepted or blocked based on the MIME type.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS window.scriptsSuccessfullyLoaded is 4
+PASS window.scriptsSuccessfullyLoaded is 8
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/http/tests/security/contentTypeOptions/nosniff-xml-external-entity.xhtml (261442 => 261443)


--- trunk/LayoutTests/http/tests/security/contentTypeOptions/nosniff-xml-external-entity.xhtml	2020-05-09 23:10:41 UTC (rev 261442)
+++ trunk/LayoutTests/http/tests/security/contentTypeOptions/nosniff-xml-external-entity.xhtml	2020-05-09 23:20:29 UTC (rev 261443)
@@ -9,6 +9,13 @@
 <!ENTITY entE SYSTEM "http://127.0.0.1:8000/security/contentTypeOptions/resources/script-with-header.pl?mime=application/pdf">
 <!ENTITY entF SYSTEM "http://127.0.0.1:8000/security/contentTypeOptions/resources/script-with-header.pl?mime=text/html">
 <!ENTITY entG SYSTEM "http://127.0.0.1:8000/security/contentTypeOptions/resources/script-with-header.pl?mime=text/_javascript_">
+<!ENTITY entNA SYSTEM "http://127.0.0.1:8000/security/contentTypeOptions/resources/script-with-header.pl?no-content-type-options=1&mime=application/xml">
+<!ENTITY entNB SYSTEM "http://127.0.0.1:8000/security/contentTypeOptions/resources/script-with-header.pl?no-content-type-options=1&mime=text/xml">
+<!ENTITY entNC SYSTEM "http://127.0.0.1:8000/security/contentTypeOptions/resources/script-with-header.pl?no-content-type-options=1&mime=application/xml-external-parsed-entity">
+<!ENTITY entND SYSTEM "http://127.0.0.1:8000/security/contentTypeOptions/resources/script-with-header.pl?no-content-type-options=1&mime=text/xml-external-parsed-entity">
+<!ENTITY entNE SYSTEM "http://127.0.0.1:8000/security/contentTypeOptions/resources/script-with-header.pl?no-content-type-options=1&mime=application/pdf">
+<!ENTITY entNF SYSTEM "http://127.0.0.1:8000/security/contentTypeOptions/resources/script-with-header.pl?no-content-type-options=1&mime=text/html">
+<!ENTITY entNG SYSTEM "http://127.0.0.1:8000/security/contentTypeOptions/resources/script-with-header.pl?no-content-type-options=1&mime=text/_javascript_">
 ]>
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
@@ -19,7 +26,7 @@
         window.scriptsSuccessfullyLoaded = 0;
 
         window._onload_ = function () {
-            shouldBe('window.scriptsSuccessfullyLoaded', '4');
+            shouldBe('window.scriptsSuccessfullyLoaded', '8');
             finishJSTest();
         };
     </script>
@@ -30,10 +37,17 @@
     <script type="text/_javascript_">&entE;</script>
     <script type="text/_javascript_">&entF;</script>
     <script type="text/_javascript_">&entG;</script>
+    <script type="text/_javascript_">&entNA;</script>
+    <script type="text/_javascript_">&entNB;</script>
+    <script type="text/_javascript_">&entNC;</script>
+    <script type="text/_javascript_">&entND;</script>
+    <script type="text/_javascript_">&entNE;</script>
+    <script type="text/_javascript_">&entNF;</script>
+    <script type="text/_javascript_">&entNG;</script>
 </head>
 <body>
     <script type="text/_javascript_">
-        description('Check that xml external entity resources loaded with an \'X-Content-Type-Options: nosniff\' header are correctly accepted or blocked based on the MIME type.');
+        description('Check that xml external entity resources loaded are correctly accepted or blocked based on the MIME type.');
     </script>
     <script src=""
 </body>

Modified: trunk/LayoutTests/http/tests/security/xss-DENIED-xsl-external-entity-redirect-expected.txt (261442 => 261443)


--- trunk/LayoutTests/http/tests/security/xss-DENIED-xsl-external-entity-redirect-expected.txt	2020-05-09 23:10:41 UTC (rev 261442)
+++ trunk/LayoutTests/http/tests/security/xss-DENIED-xsl-external-entity-redirect-expected.txt	2020-05-09 23:20:29 UTC (rev 261443)
@@ -1,2 +1,4 @@
+CONSOLE MESSAGE: Did not parse external entity resource at 'http://127.0.0.1:8000/resources/redirect.php?url="" because cross-origin loads are not allowed.
+CONSOLE MESSAGE: Did not parse external entity resource at 'http://127.0.0.1:8000/resources/redirect.php?url="" because cross-origin loads are not allowed.
 This test includes a cross-origin external entity. It passes if the load fails and thus there is no text below this line.
 

Modified: trunk/Source/WebCore/ChangeLog (261442 => 261443)


--- trunk/Source/WebCore/ChangeLog	2020-05-09 23:10:41 UTC (rev 261442)
+++ trunk/Source/WebCore/ChangeLog	2020-05-09 23:20:29 UTC (rev 261443)
@@ -1,5 +1,71 @@
 2020-05-09  David Kilzer  <[email protected]>
 
+        XML external entity resources should only be loaded from XML MIME types
+        <https://webkit.org/b/211488>
+        <rdar://problem/62869515>
+
+        Reviewed by Darin Adler.
+
+        Tests: dom/xhtml/level3/core/entitygetinputencoding03.xhtml
+               dom/xhtml/level3/core/entitygetinputencoding04.xhtml
+               dom/xhtml/level3/core/entitygetxmlencoding02.xhtml
+               dom/xhtml/level3/core/entitygetxmlencoding03.xhtml
+               dom/xhtml/level3/core/entitygetxmlencoding04.xhtml
+               dom/xhtml/level3/core/entitygetxmlversion03.xhtml
+               dom/xhtml/level3/core/entitygetxmlversion04.xhtml
+               dom/xhtml/level3/core/nodegetbaseuri16.xhtml
+               dom/xhtml/level3/core/nodegetbaseuri19.xhtml
+               dom/xhtml/level3/core/nodegetbaseuri20.xhtml
+               fast/parser/external-entities-in-xslt.xml
+               fast/xsl/dtd-in-source-document.xml
+               fast/xsl/xslt-second-level-import.xml
+               http/tests/security/contentTypeOptions/nosniff-xml-external-entity.xhtml
+               http/tests/security/xss-DENIED-xsl-external-entity-redirect.xml
+
+        * html/HTMLBaseElement.cpp:
+        (WebCore::HTMLBaseElement::href const):
+        - Add comment about keeping code in sync with openFunc() in
+          XMLDocumentParserLibxml2.cpp.
+        * xml/XMLHttpRequest.cpp:
+        (WebCore::XMLHttpRequest::responseMIMEType const):
+        - Add comment about keeping code in sync with
+          externalEntityMimeTypeAllowed() in
+          XMLDocumentParserLibxml2.cpp.
+        * xml/parser/XMLDocumentParserLibxml2.cpp:
+        (WebCore::externalEntityMimeTypeAllowed):
+        - Rename from externalEntityMimeTypeAllowedByNosniff().
+        - Change to only allow XML MIME types regardless of nosniff
+          option.
+        - Add fallback path to determine MIME type for file:/// URLs to
+          make layout tests work properly.  Logic taken from
+          XMLHttpRequest::responseMIMEType().  Not sure if there was a
+          good place to share it.
+        (WebCore::openFunc):
+        - Fix relative URLs by providing the document's URL as a base.
+          Also provide an encoding if needed.  Logic taken from
+          HTMLBaseElement::href().  (Not sure if there was a good place
+          to share it.)  This was required to fix loading of external
+          entity resources in the dom/xhtml/level3/core tests, which
+          hadn't been loading these resources for a while.  Ultimately
+          this didn't matter--except for new error messages being
+          printed in test results--because the tests fail due to missing
+          DOM features for XHTML documents).
+        - Change the fix for Bug 21963 into an empty URL check since
+          setting FetchOptions.mode to Mode::SameOrigin prevents a
+          redirect from loading a resource outside the document's
+          origin.  The previous check worked, but the relaxed check in
+          externalEntityMimeTypeAllowed() caused the XML MIME type
+          warning to be output on redirects to non-same-origin URLs.  I
+          didn't see a way to check for a cross-origin loading error.
+        - Add a console message for a cross-origin load failing.
+        - Update for function rename.
+        - Remove double negative from console message for an invalid
+          MIME type.
+        (WebCore::externalEntityMimeTypeAllowedByNosniff):
+        - Rename to externalEntityMimeTypeAllowed().
+
+2020-05-09  David Kilzer  <[email protected]>
+
         Adapt LocalCurrentGraphicsContext for iOS
         <https://webkit.org/b/211660>
 

Modified: trunk/Source/WebCore/html/HTMLBaseElement.cpp (261442 => 261443)


--- trunk/Source/WebCore/html/HTMLBaseElement.cpp	2020-05-09 23:10:41 UTC (rev 261442)
+++ trunk/Source/WebCore/html/HTMLBaseElement.cpp	2020-05-09 23:20:29 UTC (rev 261443)
@@ -89,6 +89,7 @@
     if (attributeValue.isNull())
         return document().url();
 
+    // Same logic as openFunc() in XMLDocumentParserLibxml2.cpp. Keep them in sync.
     auto* encoding = document().decoder() ? document().decoder()->encodingForURLParsing() : nullptr;
     URL url(document().url(), stripLeadingAndTrailingHTMLSpaces(attributeValue), encoding);
 

Modified: trunk/Source/WebCore/xml/XMLHttpRequest.cpp (261442 => 261443)


--- trunk/Source/WebCore/xml/XMLHttpRequest.cpp	2020-05-09 23:10:41 UTC (rev 261442)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.cpp	2020-05-09 23:20:29 UTC (rev 261443)
@@ -852,6 +852,7 @@
 {
     String mimeType = extractMIMETypeFromMediaType(m_mimeTypeOverride);
     if (mimeType.isEmpty()) {
+        // Same logic as externalEntityMimeTypeAllowed() in XMLDocumentParserLibxml2.cpp. Keep them in sync.
         String contentType;
         if (m_response.isHTTP())
             contentType = m_response.httpHeaderField(HTTPHeaderName::ContentType);

Modified: trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp (261442 => 261443)


--- trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp	2020-05-09 23:10:41 UTC (rev 261442)
+++ trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp	2020-05-09 23:20:29 UTC (rev 261443)
@@ -38,6 +38,7 @@
 #include "FrameLoader.h"
 #include "HTMLEntityParser.h"
 #include "HTMLHtmlElement.h"
+#include "HTMLParserIdioms.h"
 #include "HTMLTemplateElement.h"
 #include "HTTPParsers.h"
 #include "InlineClassicScript.h"
@@ -379,17 +380,18 @@
     unsigned m_currentOffset;
 };
 
-static bool externalEntityMimeTypeAllowedByNosniff(const ResourceResponse& response)
+static bool externalEntityMimeTypeAllowed(const ResourceResponse& response)
 {
-    ContentTypeOptionsDisposition contentTypeOption = parseContentTypeOptionsHeader(response.httpHeaderField(HTTPHeaderName::XContentTypeOptions));
-    if (contentTypeOption != ContentTypeOptionsNosniff) {
-        // Allow any MIME type without 'X-Content-Type-Options: nosniff' HTTP header.
-        return true;
+    String contentType = response.httpHeaderField(HTTPHeaderName::ContentType);
+    String mimeType = extractMIMETypeFromMediaType(contentType);
+    if (mimeType.isEmpty()) {
+        // Same logic as XMLHttpRequest::responseMIMEType(). Keep them in sync.
+        if (response.isHTTP())
+            mimeType = contentType;
+        else
+            mimeType = response.mimeType();
     }
-    String mimeType = extractMIMETypeFromMediaType(response.httpHeaderField(HTTPHeaderName::ContentType));
-    if (MIMETypeRegistry::isXMLMIMEType(mimeType) || MIMETypeRegistry::isXMLEntityMIMEType(mimeType))
-        return true;
-    return false;
+    return MIMETypeRegistry::isXMLMIMEType(mimeType) || MIMETypeRegistry::isXMLEntityMIMEType(mimeType);
 }
 
 static inline void setAttributes(Element* element, Vector<Attribute>& attributeVector, ParserContentPolicy parserContentPolicy)
@@ -452,38 +454,42 @@
     ASSERT(XMLDocumentParserScope::currentCachedResourceLoader);
     ASSERT(libxmlLoaderThread == &Thread::current());
 
-    URL url(URL(), uri);
+    CachedResourceLoader& cachedResourceLoader = *XMLDocumentParserScope::currentCachedResourceLoader;
+    Document* document = cachedResourceLoader.document();
+    // Same logic as HTMLBaseElement::href(). Keep them in sync.
+    auto* encoding = (document && document->decoder()) ? document->decoder()->encodingForURLParsing() : nullptr;
+    URL url(document ? document->url() : URL(), stripLeadingAndTrailingHTMLSpaces(uri), encoding);
 
     if (!shouldAllowExternalLoad(url))
         return &globalDescriptor;
 
-    ResourceError error;
     ResourceResponse response;
     RefPtr<SharedBuffer> data;
 
-
     {
-        CachedResourceLoader* cachedResourceLoader = XMLDocumentParserScope::currentCachedResourceLoader;
+        ResourceError error;
         XMLDocumentParserScope scope(nullptr);
         // FIXME: We should restore the original global error handler as well.
 
-        if (cachedResourceLoader->frame()) {
+        if (cachedResourceLoader.frame()) {
             FetchOptions options;
             options.mode = FetchOptions::Mode::SameOrigin;
             options.credentials = FetchOptions::Credentials::Include;
-            cachedResourceLoader->frame()->loader().loadResourceSynchronously(url, ClientCredentialPolicy::MayAskClientForCredentials, options, { }, error, response, data);
-            if (!externalEntityMimeTypeAllowedByNosniff(response)) {
-                data = ""
-                if (Page* page = cachedResourceLoader->document()->page())
-                    page->console().addMessage(MessageSource::Security, MessageLevel::Error, makeString("Did not parse external entity resource at '", url.stringCenterEllipsizedToLength(), "' because non XML External Entity MIME types are not allowed when 'X-Content-Type-Options: nosniff' is given."));
+            cachedResourceLoader.frame()->loader().loadResourceSynchronously(url, ClientCredentialPolicy::MayAskClientForCredentials, options, { }, error, response, data);
+
+            if (response.url().isEmpty()) {
+                if (Page* page = document ? document->page() : nullptr)
+                    page->console().addMessage(MessageSource::Security, MessageLevel::Error, makeString("Did not parse external entity resource at '", url.stringCenterEllipsizedToLength(), "' because cross-origin loads are not allowed."));
+                return &globalDescriptor;
             }
+            if (!externalEntityMimeTypeAllowed(response)) {
+                if (Page* page = document ? document->page() : nullptr)
+                    page->console().addMessage(MessageSource::Security, MessageLevel::Error, makeString("Did not parse external entity resource at '", url.stringCenterEllipsizedToLength(), "' because only XML MIME types are allowed."));
+                return &globalDescriptor;
+            }
         }
     }
 
-    // We have to check the URL again after the load to catch redirects.
-    // See <https://bugs.webkit.org/show_bug.cgi?id=21963>.
-    if (!shouldAllowExternalLoad(response.url()))
-        return &globalDescriptor;
     Vector<char> buffer;
     if (data)
         buffer.append(data->data(), data->size());
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to