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

Avoid duplicate markdown sanitization #210524

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/vs/base/browser/markdownRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { DomEmitter } from 'vs/base/browser/event';
import { createElement, FormattedTextRenderOptions } from 'vs/base/browser/formattedTextRenderer';
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { StandardMouseEvent } from 'vs/base/browser/mouseEvent';
import { createTrustedTypesPolicy } from 'vs/base/browser/trustedTypes';
import { renderLabelWithIcons } from 'vs/base/browser/ui/iconLabel/iconLabels';
import { onUnexpectedError } from 'vs/base/common/errors';
import { Event } from 'vs/base/common/event';
Expand All @@ -26,6 +27,8 @@ import { dirname, resolvePath } from 'vs/base/common/resources';
import { escape } from 'vs/base/common/strings';
import { URI } from 'vs/base/common/uri';

const ttPolicy = createTrustedTypesPolicy('markdownRenderer', { createHTML: value => value });

export interface MarkedOptions extends marked.MarkedOptions {
baseUrl?: never;
}
Expand Down Expand Up @@ -306,7 +309,9 @@ export function renderMarkdown(markdown: IMarkdownString, options: MarkdownRende
}
});

element.innerHTML = sanitizeRenderedMarkdown(markdown, markdownHtmlDoc.body.innerHTML) as unknown as string;
const html = markdownHtmlDoc.body.innerHTML;
const trustedhtml = ttPolicy ? ttPolicy.createHTML(html) : html;
DonJayamanne marked this conversation as resolved.
Show resolved Hide resolved
element.innerHTML = trustedhtml as string;

if (codeBlocks.length > 0) {
Promise.all(codeBlocks).then((tuples) => {
Expand Down
Loading