Skip to content

Commit

Permalink
fix(v2): escape alt text in img tag
Browse files Browse the repository at this point in the history
  • Loading branch information
lex111 committed Nov 16, 2020
1 parent cb55a2b commit 98bfa81
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ exports[`transformImage plugin transform md images to <img /> 1`] = `
<img alt={\\"img\\"} src={require(\\"!url-loader?limit=10000&name=assets/images/[name]-[hash].[ext]&fallback=file-loader!./img.png\\").default} title=\\"Title\\" /> <img alt={\\"img\\"} src={require(\\"!url-loader?limit=10000&name=assets/images/[name]-[hash].[ext]&fallback=file-loader!packages/docusaurus-mdx-loader/src/remark/transformImage/__tests__/fixtures/img.png\\").default} />
<img alt={\\"img with &quot;quotes&quot;\\"} src={require(\\"!url-loader?limit=10000&name=assets/images/[name]-[hash].[ext]&fallback=file-loader!./img.png\\").default} title=\\"&#39;Quoted&#39; title\\" />
## Heading
\`\`\`md
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

![img](./img.png 'Title') ![img](/img.png)

![img with "quotes"](./img.png ''Quoted' title')

## Heading

```md
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const {

const createJSX = (node, pathUrl) => {
node.type = 'jsx';
node.value = `<img ${node.alt ? `alt={"${node.alt}"} ` : ''}${
node.value = `<img ${node.alt ? `alt={"${escapeHtml(node.alt)}"} ` : ''}${
node.url
? `src={require("${inlineMarkdownImageFileLoader}${pathUrl}").default}`
: ''
Expand Down

0 comments on commit 98bfa81

Please sign in to comment.