fix: prevent HTML injections to code blocks (#1165)
This commit is contained in:
parent
1a4fd19720
commit
c15df78cbb
5 changed files with 88 additions and 25 deletions
|
@ -1,9 +1,36 @@
|
|||
// Vitest Snapshot v1
|
||||
|
||||
exports[`content-rich > block with backticks 1`] = `"<p><pre>[(\`number string) (\`tag string)]</pre></p>"`;
|
||||
exports[`content-rich > block with backticks 1`] = `"<p><pre class=\\"code-block\\">[(\`number string) (\`tag string)]</pre></p>"`;
|
||||
|
||||
exports[`content-rich > block with injected html, with a known language 1`] = `
|
||||
"<pre>
|
||||
<code class=\\"language-js\\">
|
||||
<a href="javascript:alert(1)">click me</a>
|
||||
</code>
|
||||
</pre>
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`content-rich > block with injected html, with an unknown language 1`] = `
|
||||
"<pre>
|
||||
<code class=\\"language-xyzzy\\">
|
||||
<a href="javascript:alert(1)">click me</a>
|
||||
</code>
|
||||
</pre>
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`content-rich > block with injected html, without language 1`] = `
|
||||
"<pre>
|
||||
<code>
|
||||
<a href="javascript:alert(1)">click me</a>
|
||||
</code>
|
||||
</pre>
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`content-rich > code frame 1`] = `
|
||||
"<p>Testing code block</p><p></p><p><pre lang=\\"ts\\">import { useMouse, usePreferredDark } from '@vueuse/core'
|
||||
"<p>Testing code block</p><p></p><p><pre class=\\"code-block\\">import { useMouse, usePreferredDark } from '@vueuse/core'
|
||||
// tracks mouse position
|
||||
const { x, y } = useMouse()
|
||||
// is the user prefers dark theme
|
||||
|
@ -20,14 +47,14 @@ exports[`content-rich > code frame 2 1`] = `
|
|||
></a
|
||||
></span>
|
||||
Testing<br />
|
||||
<pre lang=\\"ts\\">const a = hello</pre>
|
||||
<pre class=\\"code-block\\">const a = hello</pre>
|
||||
</p>
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`content-rich > code frame empty 1`] = `"<p><pre></pre><br></p>"`;
|
||||
exports[`content-rich > code frame empty 1`] = `"<p><pre class=\\"code-block\\"></pre><br></p>"`;
|
||||
|
||||
exports[`content-rich > code frame no lang 1`] = `"<p><pre>hello world</pre><br>no lang</p>"`;
|
||||
exports[`content-rich > code frame no lang 1`] = `"<p><pre class=\\"code-block\\">hello world</pre><br>no lang</p>"`;
|
||||
|
||||
exports[`content-rich > custom emoji 1`] = `
|
||||
"Daniel Roe
|
||||
|
@ -75,7 +102,7 @@ exports[`content-rich > handles formatting from servers 1`] = `
|
|||
exports[`content-rich > handles html within code blocks 1`] = `
|
||||
"<p>
|
||||
HTML block code:<br />
|
||||
<pre lang=\\"html\\">
|
||||
<pre class=\\"code-block\\">
|
||||
<span class="icon--noto icon--noto--1st-place-medal"></span>
|
||||
<span class="icon--noto icon--noto--2nd-place-medal-medal"></span></pre
|
||||
>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue