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

JSON Encoded HTML attribute issues #143

Open
breconwhite opened this issue Feb 22, 2024 · 0 comments
Open

JSON Encoded HTML attribute issues #143

breconwhite opened this issue Feb 22, 2024 · 0 comments

Comments

@breconwhite
Copy link

breconwhite commented Feb 22, 2024

What is this feature about (expected vs actual behaviour)?

When HTML is sent as part of a JSON request, xss_clean has some issues with quotations. Specifically having issues with anchor tag attributes being stripped away with the _filter_attributes function when HTML is nested and there are double-escaped quotations.

e.g. => A JSON string like
"{\"text\": \"<a href=\\\"https://google.com\\\">Google</a>\"}" returns as {\"text\": \"<a >Google</a>\"}"

Any additional information?

I think this could possibly be solved by updating the regex on line 995 in _filter_attributes to include \" as a potential attribute quote.
Maybe by updating the capture group to ("|'|\") as follows
'#\s*[\p{L}\d_\-\[\]]+\s*=\s*("|\'|\\")(?:[^\1]*?)\\1#u'

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

No branches or pull requests

1 participant