You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
XML MIME types used for documents are not interoperable #7420
interopImplementations are not interoperable with each othertopic: navigationNavigating documents, the Location interface, window.open() and fragment navigationtopic: xmlThe XML syntax and parser, DOMParser and XMLSerializer with XML, and XSLT and XPath
data:application/atom+xml,<script xmlns="http://www.w3.org/1999/xhtml">alert(1)</script> executes in Chrome and Safari, downloads in Firefox.
data:application/mathml+xml,<script xmlns="http://www.w3.org/1999/xhtml">alert(1)</script> executes in Firefox, downloads in Chrome and Safari.
No browser appears to support +xml in general. My inclination is that we should try to fix this and align browsers with the standard. Thoughts on that?
"Not explicitly supported XML MIME type": produce an XML document, using the computed navigationParams. (Notably the origin, i.e., the resulting document could be same-origin and thus script-inspectable.)
"Explicitly supported XML MIME type": proceed onward to steps 10 and 11, i.e. either display as an opaque-origin document with custom presentation, or hand off to external application/download.
Currently the spec lets engines decide what MIME types are in the "explicitly supported" set. And that seems pretty reasonable, e.g., Firefox and Safari might have MathML, whereas Chrome would not? So I'm not sure how much interop we want to demand here...
Do we have a complete matrix of all the types we'd want to consider? Maybe we should assemble one by looking at browser source code? Then we can run some tests.
Note that per that definition it would mean that application/mathml+xml is an explicitly supported XML MIME type for Chrome and Safari (because they download), but not Firefox (because it does the normal document thing). And that all browsers have application/{random}+xml as explicitly supported XML MIME types... In general I would expect that browsers don't have explicitly supported XML MIME types. That was mainly for RSS from what I remember.
Yeah, I think the term "explicitly supported" is bad, but I think maybe it's OK to have browser-dependent behavior as to whether things are downloaded/displayed-as-plugin vs. displayed-as-potentially-same-origin XML? But I dunno, maybe we could tighten that up a bit, or flip the default.
Apart from RSS and perhaps XML formats that a native app consumes I have a hard time coming up with examples. I think I would prefer a world whereby we have a set of XML MIME types that always results in a document and all others result in a download/plugin/dispatch-to-native.
IMO best next steps are to try to determine how large the divergence is. We can do this either by code inspection or blackbox testing.
I'm trying to get help finding the Chromium code; if anyone from Mozilla or WebKit could help with those that'd also be lovely. /cc @cdumez. (Context: trying to figure out whether we can/should make browsers interoperable on which XML MIME types trigger the XML tree viewer vs. downloads vs. any other option.)
Any text/* except text/html, text/xml, and text/xsl will end up as a text document. So e.g. text/foo+xml is a text document.
Otherwise we use IsXMLMimeType which has special cases for text/xml, text/xsl, application/xml, and then uses a complicated RFC-based parser to count certain x/y+xml MIME types as XML.
If there's no error (presumably an XML parsing error?) and no CSS and it's not SVG and we didn't see elements in "known namespaces", then use XML viewer mode
Otherwise... not sure exactly what the fallback is, but I suspect it could spit out either text, HTML, or SVG documents.
None of this yet explains why some cases end up downloaded. I suspect that happens in earlier code.
Not including media and image types, this is what Gecko does:
(1) (X)HTML documents: text/html, application/x-view-source, application/xhtml+xml, application/vnd.wap.xhtml+xml
(application/x-view-source is converted internally to text/plain)
(2) XML document: text/xml, application/xml, application/mathml+xml, application/rdf+xml, text/rdf
(image/svg+xml is handled similarly to items in this group when loaded as a document.)
(1) and (2) may execute scripts (except view-source which is converted to text/plain)
Random text/foo or text/foo+xml is downloaded.
XML viewer mode is used if the document is parsed as an XHTML/XML document and doesn't have XHTML nor SVG elements and there isn't a style (css or xslt) link from the header nor from a processing instruction.
To add to domenic's comment, chromium and webkit also have behavior where application/rss+xml and application/atom+xml get converted to text/plain very early in the network stack due to a security bug from 2009. There is a chrome bug with a high number of stars to get rid of this behavior and allow these mime types to be rendered with the XML tree viewer.
Here is a table for some mime types ending with +xml
content-type
Firefox
Chromium
WebKit
application/rss+xml
download
plain text
plain text
application/atom+xml
download
plain text
plain text
application/mathml+xml
execute
download
download
application/foo+xml
download
download
download
None of this yet explains why some cases end up downloaded. I suspect that happens in earlier code.
Yeah I'm not sure where that code in chromium is either.
Another thing worth considering that I found while trying to address the high star open chrome bug is that the XML tree viewer in chromium actually executes the XML file before rendering the tree viewer, so I guess that for mime types which we believe are a security issue the only options are render as plain text and download...?
Here is a more exhaustive table of test cases. I'm not going to look at whether the XML tree viewer is opened in this analysis, just executed vs plain text vs download when navigating directly to an XHTML document.
I think @josepharhar's earlier comment covers that:
chromium and webkit also have behavior where application/rss+xml and application/atom+xml get converted to text/plain very early in the network stack due to a security bug from 2009. There is a chrome bug with a high number of stars to get rid of this behavior and allow these mime types to be rendered with the XML tree viewer.
interopImplementations are not interoperable with each othertopic: navigationNavigating documents, the Location interface, window.open() and fragment navigationtopic: xmlThe XML syntax and parser, DOMParser and XMLSerializer with XML, and XSLT and XPath
Activity
domenic commentedon Dec 14, 2021
So in particular this is about what path we go down in step 9 of https://html.spec.whatwg.org/#process-a-navigate-response, where we have two choices:
Currently the spec lets engines decide what MIME types are in the "explicitly supported" set. And that seems pretty reasonable, e.g., Firefox and Safari might have MathML, whereas Chrome would not? So I'm not sure how much interop we want to demand here...
Do we have a complete matrix of all the types we'd want to consider? Maybe we should assemble one by looking at browser source code? Then we can run some tests.
annevk commentedon Dec 14, 2021
Note that per that definition it would mean that
application/mathml+xmlis an explicitly supported XML MIME type for Chrome and Safari (because they download), but not Firefox (because it does the normal document thing). And that all browsers haveapplication/{random}+xmlas explicitly supported XML MIME types... In general I would expect that browsers don't have explicitly supported XML MIME types. That was mainly for RSS from what I remember.domenic commentedon Dec 14, 2021
Yeah, I think the term "explicitly supported" is bad, but I think maybe it's OK to have browser-dependent behavior as to whether things are downloaded/displayed-as-plugin vs. displayed-as-potentially-same-origin XML? But I dunno, maybe we could tighten that up a bit, or flip the default.
annevk commentedon Dec 14, 2021
Apart from RSS and perhaps XML formats that a native app consumes I have a hard time coming up with examples. I think I would prefer a world whereby we have a set of XML MIME types that always results in a document and all others result in a download/plugin/dispatch-to-native.
domenic commentedon Mar 7, 2022
IMO best next steps are to try to determine how large the divergence is. We can do this either by code inspection or blackbox testing.
I'm trying to get help finding the Chromium code; if anyone from Mozilla or WebKit could help with those that'd also be lovely. /cc @cdumez. (Context: trying to figure out whether we can/should make browsers interoperable on which XML MIME types trigger the XML tree viewer vs. downloads vs. any other option.)
For blackbox testing, I created https://cool-massive-appendix.glitch.me/xml?contentType=application/xml , where you can change the
contentTypeparameter. Remember to encode+as%2B. Basic results so far:application/xml: tree viewer everywheretext/xml: tree viewer everywhereapplication/foo+xml: download everywhereapplication/rss+xml: download in Firefox; text document (!) in Chrome and Safaridomenic commentedon Mar 7, 2022
@jeremyroman found some of the relevant Chromium code for me:
text/*excepttext/html,text/xml, andtext/xslwill end up as a text document. So e.g.text/foo+xmlis a text document.text/xml,text/xsl,application/xml, and then uses a complicated RFC-based parser to count certainx/y+xmlMIME types as XML.None of this yet explains why some cases end up downloaded. I suspect that happens in earlier code.
smaug---- commentedon Apr 7, 2022
Not including media and image types, this is what Gecko does:
(1) (X)HTML documents: text/html, application/x-view-source, application/xhtml+xml, application/vnd.wap.xhtml+xml
(application/x-view-source is converted internally to text/plain)
(2) XML document: text/xml, application/xml, application/mathml+xml, application/rdf+xml, text/rdf
(image/svg+xml is handled similarly to items in this group when loaded as a document.)
(3) Plain text: text/plain, text/css, text/cache-manifest, text/vtt, application/javascript, application/x-javascript, text/ecmascript, application/ecmascript, text/javascript, application/json (gets json viewer), text/json
(1) and (2) may execute scripts (except view-source which is converted to text/plain)
Random text/foo or text/foo+xml is downloaded.
XML viewer mode is used if the document is parsed as an XHTML/XML document and doesn't have XHTML nor SVG elements and there isn't a style (css or xslt) link from the header nor from a processing instruction.
josepharhar commentedon Apr 7, 2022
I made a test page with all of the mime types of the last comment thrown into iframes, and there are definitely some differences between what the browsers render: https://volcano-raspy-lead.glitch.me/
WebKit and chromium seem to be mostly similar.
WebKit and chromium's XML tree viewers don't run in iframes though :(
To add to domenic's comment, chromium and webkit also have behavior where application/rss+xml and application/atom+xml get converted to text/plain very early in the network stack due to a security bug from 2009. There is a chrome bug with a high number of stars to get rid of this behavior and allow these mime types to be rendered with the XML tree viewer.
Here is a table for some mime types ending with +xml
Yeah I'm not sure where that code in chromium is either.
Another thing worth considering that I found while trying to address the high star open chrome bug is that the XML tree viewer in chromium actually executes the XML file before rendering the tree viewer, so I guess that for mime types which we believe are a security issue the only options are render as plain text and download...?
josepharhar commentedon May 2, 2022
Here is a more exhaustive table of test cases. I'm not going to look at whether the XML tree viewer is opened in this analysis, just executed vs plain text vs download when navigating directly to an XHTML document.
content-types with non-interoperable behavior:
content-types with interoperable behavior:
zcorpan commentedon Aug 27, 2025
What is the rationale for rendering application/rss+xml and application/atom+xml as plain text?
domenic commentedon Aug 27, 2025
I think @josepharhar's earlier comment covers that: