Skip to content

Commit 8414d4f

Browse files
committed
Fix bugs
1 parent 673f4ff commit 8414d4f

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/vs/base/browser/domSanitize.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,12 +278,12 @@ function replaceWithPlainTextHook(element: Element, data: dompurify.SanitizeElem
278278
}
279279

280280
export function convertTagToPlaintext(element: Element): DocumentFragment {
281-
const tagName = element.tagName.toLowerCase();
282281
let startTagText: string;
283282
let endTagText: string | undefined;
284283
if (element.nodeType === Node.COMMENT_NODE) {
285284
startTagText = `<!--${element.textContent}-->`;
286285
} else {
286+
const tagName = element.tagName.toLowerCase();
287287
const isSelfClosing = selfClosingTags.includes(tagName);
288288
const attrString = element.attributes.length ?
289289
' ' + Array.from(element.attributes)

src/vs/base/browser/markdownRenderer.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,15 @@ export function renderMarkdown(markdown: IMarkdownString, options: MarkdownRende
213213
}
214214

215215
// Remove/disable inputs
216-
for (const e of element.getElementsByTagName('input')) {
217-
if (e.attributes.getNamedItem('type')?.value === 'checkbox') {
218-
e.setAttribute('disabled', '');
216+
for (const input of element.getElementsByTagName('input')) {
217+
if (input.attributes.getNamedItem('type')?.value === 'checkbox') {
218+
input.setAttribute('disabled', '');
219219
} else {
220220
if (options.sanitizerConfig?.replaceWithPlaintext) {
221-
const replacement = convertTagToPlaintext(element);
222-
element.parentElement?.replaceChild(replacement, element);
221+
const replacement = convertTagToPlaintext(input);
222+
input.parentElement?.replaceChild(replacement, input);
223223
} else {
224-
e.remove();
224+
input.remove();
225225
}
226226
}
227227
}
@@ -464,6 +464,7 @@ export const allowedMarkdownHtmlAttributes = [
464464
'type',
465465
'width',
466466
'start',
467+
'value',
467468

468469
// Custom markdown attributes
469470
'data-code',

0 commit comments

Comments
 (0)