mirror of
https://github.com/markedjs/marked.git
synced 2026-11-30 16:48:05 +01:00
fix: reject invalid characters in HTML tag names (#4083)
This commit is contained in:
+4
-4
@@ -155,8 +155,8 @@ const html = edit(
|
||||
+ '|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)' // (4)
|
||||
+ '|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)' // (5)
|
||||
+ '|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)' // (6)
|
||||
+ '|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)' // (7) open tag
|
||||
+ '|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)' // (7) closing tag
|
||||
+ '|<(?!script|pre|style|textarea)([a-z][a-z0-9-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)' // (7) open tag
|
||||
+ '|</(?!script|pre|style|textarea)[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)' // (7) closing tag
|
||||
+ ')', 'i')
|
||||
.replace('comment', _comment)
|
||||
.replace('tag', _tag)
|
||||
@@ -432,8 +432,8 @@ const autolink = edit(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/)
|
||||
const _inlineComment = edit(_comment).replace('(?:-->|$)', '-->').getRegex();
|
||||
const tag = edit(
|
||||
'^comment'
|
||||
+ '|^</[a-zA-Z][\\w:-]*\\s*>' // self-closing tag
|
||||
+ '|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>' // open tag
|
||||
+ '|^</[a-zA-Z][a-zA-Z0-9-]*\\s*>' // self-closing tag
|
||||
+ '|^<[a-zA-Z][a-zA-Z0-9-]*(?:attribute)*?\\s*/?>' // open tag
|
||||
+ '|^<\\?[\\s\\S]*?\\?>' // processing instruction, e.g. <?php ?>
|
||||
+ '|^<![a-zA-Z]+\\s[\\s\\S]*?>' // declaration, e.g. <!DOCTYPE html>
|
||||
+ '|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>') // CDATA section
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
<p>foo <bar_baz> qux</p>
|
||||
<p>foo </a:b> qux</p>
|
||||
<p><div_></p>
|
||||
@@ -0,0 +1,5 @@
|
||||
foo <bar_baz> qux
|
||||
|
||||
foo </a:b> qux
|
||||
|
||||
<div_>
|
||||
Reference in New Issue
Block a user