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 XSS injection in image URLs (#603) #604

Merged
merged 2 commits into from
Sep 23, 2024

Conversation

Crozzers
Copy link
Contributor

This PR fixes #603.

The issue was with image URLs and code blocks. Putting a code block in the image URL (![](`code here`)) caused the URL to be hashed and protected from further modification. Code blocks are expected to contain URL unsafe characters like quotes so this is normal.

The problem was that in _protect_url, we attempt to escape any URL unsafe characters, but since the URL has been hashed it is ineffective.

This PR fixes this by completely unhashing the image URL before passing it to _protect_url, which allows special characters to be escaped

@nicholasserra
Copy link
Collaborator

LGTM thank you!

@nicholasserra nicholasserra merged commit ded5e74 into trentm:master Sep 23, 2024
15 checks passed
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.

XSS in escape safe mode
2 participants