Skip to content

Commit

Permalink
[XSS] Ignore case of blacklisted HTML elements (#247)
Browse files Browse the repository at this point in the history
* Ignore case of blacklisted HTML elements

* Only use lowercased tagname if blacklisted element
  • Loading branch information
jakelazaroff authored and quantizor committed May 29, 2019
1 parent 9570018 commit dab7b5d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
12 changes: 12 additions & 0 deletions index.compiler.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2389,6 +2389,18 @@ $25
new Date();
</script>
`);
});

it('does not parse the inside of <script> blocks with weird capitalization', () => {
render(compiler(['<SCRIPT>', ' new Date();', '</SCRIPT>'].join('\n')));

expect(root.innerHTML).toMatchInlineSnapshot(`
<script data-reactroot>
new Date();
</script>
`);
});

Expand Down
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1025,8 +1025,9 @@ export function compiler(markdown, options) {
? parseBlock
: parseInline;

const tagName = capture[1].toLowerCase();
const noInnerParse =
DO_NOT_PROCESS_HTML_ELEMENTS.indexOf(capture[1]) !== -1;
DO_NOT_PROCESS_HTML_ELEMENTS.indexOf(tagName) !== -1;

return {
attrs: attrStringToMap(capture[2]),
Expand All @@ -1038,7 +1039,7 @@ export function compiler(markdown, options) {

noInnerParse,

tag: capture[1],
tag: noInnerParse ? tagName : capture[1]
};
},
react(node, output, state) {
Expand Down

0 comments on commit dab7b5d

Please sign in to comment.