Skip to content

Commit 8e83fb3

Browse files
committed
Allow disabled checkbox inputs for markdown
1 parent c915ea1 commit 8e83fb3

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/vs/base/browser/markdownRenderer.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,11 @@ function sanitizeRenderedMarkdown(
424424
return domSanitize.sanitizeHtml(renderedMarkdown, sanitizerConfig);
425425
}
426426

427+
export const allowedMarkdownHtmlTags = Object.freeze([
428+
...domSanitize.basicMarkupHtmlTags,
429+
'input', // Allow inputs for rendering checkboxes. Other types of inputs are removed and the inputs are always disabled
430+
]);
431+
427432
export const allowedMarkdownHtmlAttributes = [
428433
'align',
429434
'autoplay',
@@ -483,7 +488,7 @@ function getSanitizerOptions(isTrusted: boolean | MarkdownStringTrustedOptions,
483488
// HTML tags that can result from markdown are from reading https://spec.commonmark.org/0.29/
484489
// HTML table tags that can result from markdown are from https://github.github.com/gfm/#tables-extension-
485490
allowedTags: {
486-
override: options.allowedTags?.override ?? domSanitize.basicMarkupHtmlTags
491+
override: options.allowedTags?.override ?? allowedMarkdownHtmlTags
487492
},
488493
allowedAttributes: {
489494
override: allowedMarkdownHtmlAttributes,

src/vs/workbench/contrib/chat/browser/chatMarkdownRenderer.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { IOpenerService } from '../../../../platform/opener/common/opener.js';
1818
import product from '../../../../platform/product/common/product.js';
1919
import { REVEAL_IN_EXPLORER_COMMAND_ID } from '../../files/browser/fileConstants.js';
2020

21-
export const allowedChatMarkdownHtmlTags = [
21+
export const allowedChatMarkdownHtmlTags = Object.freeze([
2222
'b',
2323
'blockquote',
2424
'br',
@@ -53,7 +53,9 @@ export const allowedChatMarkdownHtmlTags = [
5353
// Not in the official list, but used for codicons and other vscode markdown extensions
5454
'span',
5555
'div',
56-
];
56+
57+
'input', // Allowed for rendering checkboxes. Other types of inputs are removed and the inputs are always disabled
58+
]);
5759

5860
/**
5961
* This wraps the MarkdownRenderer and applies sanitizer options needed for Chat.

0 commit comments

Comments
 (0)