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 base64 images being corrupted in safe mode (issue #526) #527

Merged
merged 2 commits into from Sep 12, 2023

Conversation

Crozzers
Copy link
Contributor

This PR fixes #526 by not escaping certain base64 characters in URLs when an image data URL is detected.

It works by adding a step to _protect_url that checks if the URL matches the data URL format. The format allows for a MIME type, an optional base64 token and then the data. If the MIME type starts with image/ and the base64 token is present, then the charset of the URL is assumed to be base64.

An additional parameter is then passed to _hash_escape_url which skips encoding the + sign. It's important to note that the charset of the URL isn't validated in any way, so it may contain other characters as well.

@nicholasserra
Copy link
Collaborator

LGTM thanks!

@nicholasserra nicholasserra merged commit 2ef5653 into trentm:master Sep 12, 2023
18 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.

base64 images links in safe mode become corrupted
2 participants