mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
Fix broken codeblocks (#213399)
* Fix broken codeblocks Fix #213382 * Fix tests
This commit is contained in:
parent
1e1afd0dd7
commit
b9fa819edd
|
@ -39,8 +39,10 @@ const allowedHtmlTags = [
|
|||
'a',
|
||||
'img',
|
||||
|
||||
// TODO@roblourens when we sanitize attributes in markdown source, we can ban these elements at that step. microsoft/vscode-copilot#5091
|
||||
// Not in the official list, but used for codicons and other vscode markdown extensions
|
||||
'span',
|
||||
'div',
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
@ -1 +1 @@
|
|||
<div class="rendered-markdown"><!-- comment1 <div></div> --><div>content</div><!-- comment2 --></div>
|
||||
<div class="rendered-markdown"><!-- comment1 <div></div> --><div>content</div><!-- comment2 --></div>
|
|
@ -1 +1 @@
|
|||
<div class="rendered-markdown">1<canvas>2<div>3</div></canvas>4</div>
|
||||
<div class="rendered-markdown">1<canvas>2<details>3</details></canvas>4</div>
|
|
@ -1 +1 @@
|
|||
<div class="rendered-markdown">1<div id="id1" style="display: none">2<div id="my id 2">3</div></div>4</div>
|
||||
<div class="rendered-markdown">1<details id="id1" style="display: none">2<details id="my id 2">3</details></details>4</div>
|
|
@ -1,8 +1,8 @@
|
|||
<div class="rendered-markdown"><h1>heading</h1>
|
||||
<div>
|
||||
<details>
|
||||
<ul>
|
||||
<li><span><div><i>1</i></div></span></li>
|
||||
<li><span><details><i>1</i></details></span></li>
|
||||
<li><b>hi</b></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
<pre><canvas>canvas here</canvas></pre><details></details></div>
|
|
@ -1 +1 @@
|
|||
<div class="rendered-markdown"><img src="http://allowed.com/image.jpg"> <div><img src="http://disallowed.com/image.jpg"></div></div>
|
||||
<div class="rendered-markdown"><img src="http://allowed.com/image.jpg"> <div><img src="http://disallowed.com/image.jpg"></div></div>
|
|
@ -28,14 +28,14 @@ suite('ChatMarkdownRenderer', () => {
|
|||
});
|
||||
|
||||
test('invalid HTML', async () => {
|
||||
const md = new MarkdownString('1<canvas>2<div>3</div></canvas>4');
|
||||
const md = new MarkdownString('1<canvas>2<details>3</details></canvas>4');
|
||||
md.supportHtml = true;
|
||||
const result = store.add(testRenderer.render(md));
|
||||
await assertSnapshot(result.element.outerHTML);
|
||||
});
|
||||
|
||||
test('invalid HTML with attributes', async () => {
|
||||
const md = new MarkdownString('1<div id="id1" style="display: none">2<div id="my id 2">3</div></div>4');
|
||||
const md = new MarkdownString('1<details id="id1" style="display: none">2<details id="my id 2">3</details></details>4');
|
||||
md.supportHtml = true;
|
||||
const result = store.add(testRenderer.render(md));
|
||||
await assertSnapshot(result.element.outerHTML);
|
||||
|
@ -57,12 +57,12 @@ suite('ChatMarkdownRenderer', () => {
|
|||
test('mixed valid and invalid HTML', async () => {
|
||||
const md = new MarkdownString(`
|
||||
<h1>heading</h1>
|
||||
<div>
|
||||
<details>
|
||||
<ul>
|
||||
<li><span><div><i>1</i></div></span></li>
|
||||
<li><span><details><i>1</i></details></span></li>
|
||||
<li><b>hi</b></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
<pre><canvas>canvas here</canvas></pre><details></details>`);
|
||||
md.supportHtml = true;
|
||||
const result = store.add(testRenderer.render(md));
|
||||
|
|
Loading…
Reference in a new issue