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

x/net/html: self closing tags with unquoted attributes mistake trailing slashes as attribute values #64330

Open
empijei opened this issue Nov 22, 2023 · 1 comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@empijei
Copy link
Contributor

empijei commented Nov 22, 2023

Hi there,

here is a playground link, but I can summarize:

This piece of HTML:

<img src=/foo/>

Gets correctly parsed by the tokenizer as being a self-closing tag.

This means that the last slash is part of the tag, not of the src attribute.

But if you run the playground code, you get this:

SelfClosingTag "<img src=/foo/>"
↳ TagName: "img" Type: SelfClosingTag
↳ Attr: key:"src" val:"/foo/"

So the trailing slash is both interpreted as the closing tag and as the attribute value.

The correct parsing should be to have the attribute value to be "/foo", not "/foo/".

EDIT

This also affect "Parse", so parsing and rendering the above example renders it as

<html><head></head><body><img src="/foo/"/></body></html>

playground

@gopherbot gopherbot added this to the Unreleased milestone Nov 22, 2023
@mknyszek mknyszek added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Nov 22, 2023
@mknyszek
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants