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: escape invalid lang characters (XSS) #14

Merged
merged 1 commit into from Nov 15, 2020

Conversation

ooooooo-q
Copy link
Contributor

I found XSS in inline code highlighting.

Example

`console.log(42)`{."><img onerror=alert(1) src=.>js}

Results

<p><code class="language-"><img onerror=alert(1) src=.>js"></code></p>

Similar problem: jGleitz/markdown-it-prism#137

@valeriangalliat
Copy link
Owner

Good find, thank you!

I'm thinking of tweaking it to escape everything inbetween the {} instead, like it was done for the markdown-it-prism issue you linked, something like this (on line 52):

const cls = lang ? ` class="${options.langPrefix}${md.utils.escapeHtml(lang)}"` : ''

Do you think that would make sense as well?

@valeriangalliat valeriangalliat merged commit 1f2429c into valeriangalliat:master Nov 15, 2020
@ooooooo-q
Copy link
Contributor Author

Certainly. If can use escapeHtml, it seems better.

@ooooooo-q ooooooo-q deleted the fix/escape branch November 15, 2020 23:19
@valeriangalliat
Copy link
Owner

👍 the patch is live on 3.3.1, thanks again!

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.

None yet

2 participants