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

Consider allowing class on code tag in basic_html #9

Closed
michalmuskala opened this issue Aug 21, 2016 · 7 comments
Closed

Consider allowing class on code tag in basic_html #9

michalmuskala opened this issue Aug 21, 2016 · 7 comments

Comments

@michalmuskala
Copy link

Scrubbing with basic_html works great as a sanitisation pass after converting markdown. There's one issue.

Markdown parsers, that allow for github flavoured markdown, will add class to the code tag with the language name. Currently that class is removed (as are all class attributes). I understand the intent of removing all attributes, but it makes the scrubber unwieldy for working with markdown and requires implementing custom module.

@rrrene
Copy link
Owner

rrrene commented Aug 21, 2016

Agree. 👍

My first gut reaction would be to implement a Markdown sanitizer rather than changing the BasicHTML sanitizer's behaviour.

WDYT?

@michalmuskala
Copy link
Author

Oh, a special markdown sanitizer sounds like a great idea!

rrrene added a commit that referenced this issue Sep 9, 2016
As thought up in #9
@rrrene
Copy link
Owner

rrrene commented Sep 9, 2016

@michalmuskala Sorry for not responding here. In my defense, there was this "ElixirConf" going on that occupied my mind 😁

I created a possible iteration of this here. One thing I noticed: Should we allow target="..." on <a>? In practise we might want to set it to _blank in our Markdown parser ...

@ericmj We talked about this briefly in Florida. Any input from you is highly appreciated! 👍

@ericmj
Copy link

ericmj commented Sep 11, 2016

Only allowing target="_blank" makes sense.

@aphillipo
Copy link

If allowing target="_blank" you should also allow rel="noopener" and/or rel="noreferrer" to prevent information leakage and window.opener freakery...

https://mathiasbynens.github.io/rel-noopener/

@rrrene
Copy link
Owner

rrrene commented Sep 15, 2016

@aphillipo That's a valid point!

@rrrene
Copy link
Owner

rrrene commented Nov 10, 2016

I just released v1.1.0 of html_sanitize_ex, which includes the new scrubber. Use HtmlSanitizeEx.markdown_html/1 to sanitize HTML generated by a Markdown parser.

This was tested on elixirstatus.com for the last two weeks by depending on v1.1.0-rc1. Please report any bugs I overlooked!

@rrrene rrrene closed this as completed Nov 10, 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

4 participants