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

fix: use proper encoding for attr name / val pairs #103

Merged
merged 2 commits into from
Oct 1, 2022

Conversation

harlan-zw
Copy link
Collaborator

Issue

See #59

The encoding is too aggressive. it assumes that the value component of the attribute isn't quoted.

Properly quoted attributes can only be escaped with the corresponding quote.

Solution

Separately encode the attribute name more aggressively, stripping any unsupported characters.

For attribute values, we encode the " character to avoid escaping, and we use encode <> otherwise they will cause the HTML to be invalid.

If the intention of this encoding was to avoid XSS issues, then it's kind of pointless (see second test example). If we're simply encoding to avoid accidental scope scapes then this should be fine.

@harlan-zw harlan-zw marked this pull request as ready for review September 22, 2022 05:41
@harlan-zw
Copy link
Collaborator Author

Hey @pi0

Would you mind reviewing this one, some obvious overlap with the work you're doing but figured we should fix this bug sooner rather than later

@pi0
Copy link

pi0 commented Sep 22, 2022

I like current checks. On a related situation (in h3) made some changes to reduce aggressive encoding/escaping for src attr. The main issue was XSS so you might double-check but so far couldn't find any issue by only escaping " and <> for value.

@harlan-zw harlan-zw merged commit 669f520 into vueuse:main Oct 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants