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
It's unclear what destination value should be used for SVG documents and different browsers seem to be doing different things, at least when it comes to CSP.
At the same time, because SVG document resources are internally represented differently than images in Chromium, an as value of "image" for preloads is a mismatch for SVG documents.
Looking at Fetching the document over in SVG-land doesn't mention destination at all.
We should decide what the destination be, and then align spec and implementations on it.
My personal vote would be for a brand new destination (e.g. "svg" or "svg-document"), to make it easier to explain to developers which CSP or as values control these loads.
Reacted by Nicolas Hoizey, alexgagnon, Caesar Schinas, Bohdan Petrov, toastal and Ryan Christian
Another point to consider: the SVG document, when loaded using a <use> tag, doesn't seem to be able to run script, so maybe an "image" destination is the right call (and the Chromium implementation would have to somehow deal with that SVG documents are images too).
I guess I don't know why we'd want them to be distinct destinations. Why distinguish it as an SVG? image seems fine. Likewise, the CSP behavior seems like a bug in Firefox: img-src seems like it should control SVGs just like <img>.
I thought we may want another destination when I wasn't sure if these SVGs can run script, but looks like they can't. So, I'm fine with aligning them as an "image" destination and aligning Chromium's implementation to deal with that when it comes to preload. (I'm not sure if ResourceType::kSVGDocument is something we can get rid of, but that would be the cleanest...)
I think we should figure out why ResourceType::kSVGDocument is a thing first. If it only exists for non-web consumers, I agree we should go with image, but otherwise...
Coincidentally I recently looked into why svg subresource requests (e.g. in <use href>) are classified as "other" rather than "image" in Firefox, at https://bugzilla.mozilla.org/show_bug.cgi?id=1624471#c5. I'm not authorative here, but I would think that "image" makes more sense in this case than "other" or "document".
Here are Chromium's code search results for kSVGDocument.
From brief scanning I think it's mostly impacting a couple of error messages, but not much more than that...
I am changing Firefox (bug 1773976) to treat CSS filter: url("foo.svg#bar") and SVG <use> as "image", primarily because we were running into web-compatibility issues with CSP img-src not applying to these SVG loads.
Could this be codified? I think there is currently no WPT for this behavior.
Another point to consider: the SVG document, when loaded using a <use> tag, doesn't seem to be able to run script, so maybe an "image" destination is the right call (and the Chromium implementation would have to somehow deal with that SVG documents are images too).
Ultimately the filter property and <use> element specifications will need to set destination where they define their fetching pipeline (but I realize they probably don't).
An intermediate fix might be updating the table in Fetch and adding web-platform-tests, but it seems very concerning to classify <use> as "image". cc @whatwg/security
From a theoretical stand point, I guess it would make sense to have a new destination type? The "cloning" behavior with <use> is not easily covered by something like "iframe" and should get their own type for the most appropriate handling.
I am OK with treating image-related uses of SVG as image. But that all being said, some of these things seem unfortunately codified in the web platforms by e.g., the de-facto handling of svg like image in some parts of Chrome (at least CSP. We have not looked more closely)
Activity
yoavweiss commentedon Mar 27, 2020
Another point to consider: the SVG document, when loaded using a
<use>tag, doesn't seem to be able to run script, so maybe an "image" destination is the right call (and the Chromium implementation would have to somehow deal with that SVG documents are images too)./cc @yutakahirano @mikewest
annevk commentedon Mar 27, 2020
It would be interesting to know why they are a separate type in Chromium.
@ckerschb do you know what Firefox does here and why?
mikewest commentedon Mar 27, 2020
I guess I don't know why we'd want them to be distinct destinations. Why distinguish it as an SVG?
imageseems fine. Likewise, the CSP behavior seems like a bug in Firefox:img-srcseems like it should control SVGs just like<img>.yoavweiss commentedon Mar 27, 2020
I thought we may want another destination when I wasn't sure if these SVGs can run script, but looks like they can't. So, I'm fine with aligning them as an "image" destination and aligning Chromium's implementation to deal with that when it comes to preload. (I'm not sure if
ResourceType::kSVGDocumentis something we can get rid of, but that would be the cleanest...)annevk commentedon Mar 27, 2020
I think we should figure out why
ResourceType::kSVGDocumentis a thing first. If it only exists for non-web consumers, I agree we should go withimage, but otherwise...Rob--W commentedon Mar 27, 2020
Coincidentally I recently looked into why svg subresource requests (e.g. in
<use href>) are classified as "other" rather than "image" in Firefox, at https://bugzilla.mozilla.org/show_bug.cgi?id=1624471#c5. I'm not authorative here, but I would think that "image" makes more sense in this case than "other" or "document".yoavweiss commentedon Mar 27, 2020
Here are Chromium's code search results for kSVGDocument.
From brief scanning I think it's mostly impacting a couple of error messages, but not much more than that...
It also seems Chromium is explicitly translating it to an "image" destination
evilpie commentedon Sep 9, 2024
I am changing Firefox (bug 1773976) to treat CSS
filter: url("foo.svg#bar")and SVG<use>as"image", primarily because we were running into web-compatibility issues with CSP img-src not applying to these SVG loads.Could this be codified? I think there is currently no WPT for this behavior.
yoavweiss commentedon Sep 9, 2024
^^ @noamr
longsonr commentedon Sep 11, 2024
While neither use, nor image will run script within <script> tags.
Add tentative WPT for SVG <use> fetch destination.
Bug 1918039 - Add tentative WPT for SVG <use> fetch destination. r=em…
Bug 1918039 - Add tentative WPT for SVG <use> fetch destination. r=em…
Add tentative WPT for SVG <use> fetch destination.
Bug 1918039 - Add tentative WPT for SVG <use> fetch destination. r=em…
Bug 1918039 - Add tentative WPT for SVG <use> fetch destination. r=em…
Bug 1918039 - Add tentative WPT for SVG <use> fetch destination. r=em…
annevk commentedon Sep 25, 2024
Using
imagefor<use>seems very fraught.Ultimately the
filterproperty and<use>element specifications will need to set destination where they define their fetching pipeline (but I realize they probably don't).An intermediate fix might be updating the table in Fetch and adding web-platform-tests, but it seems very concerning to classify
<use>as "image". cc @whatwg/securitymozfreddyb commentedon Sep 27, 2024
From a theoretical stand point, I guess it would make sense to have a new destination type? The "cloning" behavior with
<use>is not easily covered by something like "iframe" and should get their own type for the most appropriate handling.I am OK with treating image-related uses of SVG as
image. But that all being said, some of these things seem unfortunately codified in the web platforms by e.g., the de-facto handling ofsvglikeimagein some parts of Chrome (at least CSP. We have not looked more closely)Bug 1918039 - Add tentative WPT for SVG <use> fetch destination. r=em…