简体   繁体   中英

Resource interpreted as Document but transferred with MIME type image/svg+xml:

When I have an SVG picture with JavaScript chrome says 'Resource interpreted as Document but transferred with MIME type image/svg+xml'. I can include it with iframe or embed TAG same result. But when I change the mime type to something different the browser cannot render it. So i guess "image/svg+xml" is correct?

SVG

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg version="1.1" baseProfile="full" id="draw" 
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
viewBox="0 0 480 480"> 
<defs>
<style type="text/css">
<![CDATA[
]]>
</style>
</defs>
<rect x="0" y="0" width="480" height="480" rx="0" ry="0" fill="rgb(255, 255, 255)" />

</g>
<script type="text/ecmascript"><![CDATA[
(function () { 

//Some code here

}());
]]>
</script>
</svg>

是的, image/svg+xml是SVG内容的正确互联网媒体类型,请参阅IANA

I had this problem for a long time but it appears application/svg-xml is the correct mime.

Refer to this https://github.com/w3c/svgwg/issues/266 for more details. The mime/svg-xml may be vulnerable too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM