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

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

Merged
merged 4 commits into from
Jun 10, 2022

Conversation

a-stewart
Copy link
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.

@@ -108,13 +108,13 @@ export function renderMarkdown(markdown: IMarkdownString, options: MarkdownRende
let attributes: string[] = [];
if (href) {
({ href, dimensions } = parseHrefAndDimensions(href));
attributes.push(`src="${href}"`);
attributes.push(`src="${href.replace(/"/g, '"')}"`);
Copy link
Collaborator

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
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 a-stewart marked this pull request as ready for review May 17, 2022 23:39
@mjbvz mjbvz added this to the June 2022 milestone Jun 10, 2022
@mjbvz mjbvz enabled auto-merge (squash) June 10, 2022 16:03
@mjbvz mjbvz disabled auto-merge June 10, 2022 17:15
@mjbvz mjbvz enabled auto-merge (squash) June 10, 2022 17:16
@mjbvz mjbvz closed this Jun 10, 2022
auto-merge was automatically disabled June 10, 2022 18:20

Pull request was closed

@mjbvz mjbvz reopened this Jun 10, 2022
@mjbvz 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