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

Data URI's get sanitized #51

Closed
Qqwy opened this issue Feb 18, 2016 · 3 comments
Closed

Data URI's get sanitized #51

Qqwy opened this issue Feb 18, 2016 · 3 comments

Comments

@Qqwy
Copy link

Qqwy commented Feb 18, 2016

When I sanitize a HTML string with an image whose src points to a data URI, its src attribute is removed (even when src is whitelisted):

unclean_html = "A test
<img src=\"http://placehold.it/400x300\">
<img src='data:image/gif;base64,R0lGODlhAQABAPAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='/>"
sanitizer = Rails::Html::WhiteListSanitizer.new
clean_html = sanitizer.sanitize(unclean_html, tags: %w{img}, attributes: %w{src})
clean_html
# => "A test\n    <img src=\"http://placehold.it/400x300\">\n    <img>"

I presume that this happens because of too strict JS-prevention measures (or the data-URI is just discarded because the sanitizer does not understand the protocol?).

@Qqwy
Copy link
Author

Qqwy commented Feb 18, 2016

After testing this, it seems that the issue is also apparent inside of Loofah, so I think it is not caused by the code in rails-html-sanitizer itself.

I've created an issue at the Loofah repository.

@flavorjones
Copy link
Member

This issue should be closed, since we have a conversation going on at flavorjones/loofah#101

@kaspth
Copy link
Contributor

kaspth commented Mar 4, 2016

Thanks folks! I'll close ❤️

@kaspth kaspth closed this as completed Mar 4, 2016
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

3 participants