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

Disallowed Raw HTML (extension) #608

Open
freedit-dev opened this issue Aug 31, 2022 · 2 comments
Open

Disallowed Raw HTML (extension) #608

freedit-dev opened this issue Aug 31, 2022 · 2 comments

Comments

@freedit-dev
Copy link

https://github.github.com/gfm/#disallowed-raw-html-extension-

Is there any plan to implement this?

@ssokolow
Copy link

ssokolow commented Apr 6, 2023

Honestly, that looks like scope creep and an opportunity for security vulnerabilities to creep in. It'd make more sense to just configure Ammonia to do that and run it on the output of your Markdown.

@GKnirps
Copy link

GKnirps commented Jul 16, 2023

I use a workaround when I want to disallow all raw HTML:

let parser = Parser::new(input);
let escaped = parser
            .into_iter()
            .map(|event| match event {
                Event::Html(html) => Event::Text(html),
                _ => event,
            });

This way, all raw HTML is escaped. You can then use escaped to render as input to the HTML render function.

If you want to allow some html, I would recommend to use an external sanitizer and do something like

let parser = Parser::new(input);
let sanitized = parser
            .into_iter()
            .map(|event| match event {
                Event::Html(html) => Event::Html(sanitize(html)),
                _ => event,
            });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants