Skip to content

Add more sanitization around the attributes in MD generated HTML - #149100

Merged
Matt Bierner (mjbvz) merged 4 commits into
microsoft:mainfrom
a-stewart:markdown-sanit
Jun 10, 2022
Merged

Add more sanitization around the attributes in MD generated HTML#149100
Matt Bierner (mjbvz) merged 4 commits into
microsoft:mainfrom
a-stewart:markdown-sanit

Conversation

@a-stewart

Copy link
Copy Markdown
Contributor

When generating a link, we URL encode the value passed in as the href value.

We don't need to do it quite to aggressively elsewhere, but it would be good to add a bit of extra protection against html code being injected here.

Comment thread src/vs/base/browser/markdownRenderer.ts Outdated
if (href) {
({ href, dimensions } = parseHrefAndDimensions(href));
attributes.push(`src="${href}"`);
attributes.push(`src="${href.replace(/"/g, '"')}"`);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should likely be extracted to its own function instead of repeated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@a-stewart
Anthony Stewart (a-stewart) marked this pull request as ready for review May 17, 2022 23:39
@mjbvz Matt Bierner (mjbvz) added this to the June 2022 milestone Jun 10, 2022
@mjbvz
Matt Bierner (mjbvz) enabled auto-merge (squash) June 10, 2022 16:03
@mjbvz
Matt Bierner (mjbvz) enabled auto-merge (squash) June 10, 2022 17:16
auto-merge was automatically disabled June 10, 2022 18:20

Pull request was closed

@mjbvz
Matt Bierner (mjbvz) merged commit 8d8e85c into microsoft:main Jun 10, 2022
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants