Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow data:image in srcset. And the U+002C COMMA character (,) issue #10292

Open
janmazanek opened this issue Apr 22, 2024 · 3 comments
Open

Comments

@janmazanek
Copy link

What is the issue with the HTML Standard?

According to https://html.spec.whatwg.org/multipage/images.html#srcset-attributes the srcset attribute may not contain ",":
4.8.4.2.1 Srcset attributes > 2: "A valid non-empty URL that does not start or end with a U+002C COMMA character (,)"

How should a "U+002C COMMA character (,)" be escaped/replaced, if it is within an URL? Or in my particular case in data:image?

I wasn't able to escape: "data:image/svg+xml," (,)
with: "data:image/svg+xml%2C" (%2C)
in: srcset="data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20width%3D%27472%27%20height%3D%27314%27%20viewBox%3D%270%200%20472%20314%27%3E%3Crect%20width%3D%27472%27%20height%3D%27314%27%20fill-opacity%3D%220%22%2F%3E%3C%2Fsvg%3E ...."

Notices:
1) I came here from https://github.com/orgs/rehypejs/discussions/78#discussioncomment-1632589, where is described similar issue with URLs without data:image

2) I'm sorry, if this is not a specification issue. In this case, I would kindly ask you, if you could send me a link to a solution (and possibly add it also to https://html.spec.whatwg.org/multipage/images.html#srcset-attributes)

@myakura
Copy link

myakura commented Apr 22, 2024

How should a "U+002C COMMA character (,)" be escaped/replaced, if it is within an URL? Or in my particular case in data:image?

does the data URL ever starts with a comma?

@YummyBacon5
Copy link

does the data URL ever starts with a comma?

Yes, data:, is the shortest which it can be

@myakura
Copy link

myakura commented Apr 22, 2024

Yes, data:, is the shortest which it can be

oh. didn't think data URLs can end with ,. but aren't data URLs are, in most cases, "A valid non-empty URL that does not start or end with a U+002C COMMA character (,)" so can just placed safely in the secret attribute?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants