Merge pull request #97 from quarterto/master
Don't infinite loop on NUL characters
This commit is contained in:
commit
f54d6eefe7
@ -17,7 +17,7 @@ var block = {
|
|||||||
heading: /^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,
|
heading: /^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,
|
||||||
lheading: /^([^\n]+)\n *(=|-){3,} *\n*/,
|
lheading: /^([^\n]+)\n *(=|-){3,} *\n*/,
|
||||||
blockquote: /^( *>[^\n]+(\n[^\n]+)*\n*)+/,
|
blockquote: /^( *>[^\n]+(\n[^\n]+)*\n*)+/,
|
||||||
list: /^( *)(bull) [^\0]+?(?:hr|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
|
list: /^( *)(bull) [\s\S]+?(?:hr|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
|
||||||
html: /^ *(?:comment|closed|closing) *(?:\n{2,}|\s*$)/,
|
html: /^ *(?:comment|closed|closing) *(?:\n{2,}|\s*$)/,
|
||||||
def: /^ *\[([^\]]+)\]: *([^\s]+)(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,
|
def: /^ *\[([^\]]+)\]: *([^\s]+)(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,
|
||||||
paragraph: /^([^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+\n*/,
|
paragraph: /^([^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+\n*/,
|
||||||
@ -36,8 +36,8 @@ block.list = replace(block.list)
|
|||||||
();
|
();
|
||||||
|
|
||||||
block.html = replace(block.html)
|
block.html = replace(block.html)
|
||||||
('comment', /<!--[^\0]*?-->/)
|
('comment', /<!--[\s\S]*?-->/)
|
||||||
('closed', /<(tag)[^\0]+?<\/\1>/)
|
('closed', /<(tag)[\s\S]+?<\/\1>/)
|
||||||
('closing', /<tag(?:"[^"]*"|'[^']*'|[^'">])*?>/)
|
('closing', /<tag(?:"[^"]*"|'[^']*'|[^'">])*?>/)
|
||||||
(/tag/g, tag())
|
(/tag/g, tag())
|
||||||
();
|
();
|
||||||
@ -57,7 +57,7 @@ block.normal = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
block.gfm = {
|
block.gfm = {
|
||||||
fences: /^ *(```|~~~) *(\w+)? *\n([^\0]+?)\s*\1 *(?:\n+|$)/,
|
fences: /^ *(```|~~~) *(\w+)? *\n([\s\S]+?)\s*\1 *(?:\n+|$)/,
|
||||||
paragraph: /^/
|
paragraph: /^/
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -298,19 +298,19 @@ var inline = {
|
|||||||
escape: /^\\([\\`*{}\[\]()#+\-.!_>])/,
|
escape: /^\\([\\`*{}\[\]()#+\-.!_>])/,
|
||||||
autolink: /^<([^ >]+(@|:\/)[^ >]+)>/,
|
autolink: /^<([^ >]+(@|:\/)[^ >]+)>/,
|
||||||
url: noop,
|
url: noop,
|
||||||
tag: /^<!--[^\0]*?-->|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,
|
tag: /^<!--[\s\S]*?-->|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,
|
||||||
link: /^!?\[(inside)\]\(href\)/,
|
link: /^!?\[(inside)\]\(href\)/,
|
||||||
reflink: /^!?\[(inside)\]\s*\[([^\]]*)\]/,
|
reflink: /^!?\[(inside)\]\s*\[([^\]]*)\]/,
|
||||||
nolink: /^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,
|
nolink: /^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,
|
||||||
strong: /^__([^\0]+?)__(?!_)|^\*\*([^\0]+?)\*\*(?!\*)/,
|
strong: /^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,
|
||||||
em: /^\b_((?:__|[^\0])+?)_\b|^\*((?:\*\*|[^\0])+?)\*(?!\*)/,
|
em: /^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,
|
||||||
code: /^(`+)([^\0]*?[^`])\1(?!`)/,
|
code: /^(`+)([\s\S]*?[^`])\1(?!`)/,
|
||||||
br: /^ {2,}\n(?!\s*$)/,
|
br: /^ {2,}\n(?!\s*$)/,
|
||||||
text: /^[^\0]+?(?=[\\<!\[_*`]| {2,}\n|$)/
|
text: /^[\s\S]+?(?=[\\<!\[_*`]| {2,}\n|$)/
|
||||||
};
|
};
|
||||||
|
|
||||||
inline._linkInside = /(?:\[[^\]]*\]|[^\]]|\](?=[^\[]*\]))*/;
|
inline._linkInside = /(?:\[[^\]]*\]|[^\]]|\](?=[^\[]*\]))*/;
|
||||||
inline._linkHref = /\s*<?([^\s]*?)>?(?:\s+['"]([^\0]*?)['"])?\s*/;
|
inline._linkHref = /\s*<?([^\s]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/;
|
||||||
|
|
||||||
inline.link = replace(inline.link)
|
inline.link = replace(inline.link)
|
||||||
('inside', inline._linkInside)
|
('inside', inline._linkInside)
|
||||||
@ -329,13 +329,13 @@ inline.normal = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
inline.pedantic = {
|
inline.pedantic = {
|
||||||
strong: /^__(?=\S)([^\0]*?\S)__(?!_)|^\*\*(?=\S)([^\0]*?\S)\*\*(?!\*)/,
|
strong: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
|
||||||
em: /^_(?=\S)([^\0]*?\S)_(?!_)|^\*(?=\S)([^\0]*?\S)\*(?!\*)/
|
em: /^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/
|
||||||
};
|
};
|
||||||
|
|
||||||
inline.gfm = {
|
inline.gfm = {
|
||||||
url: /^(https?:\/\/[^\s]+[^.,:;"')\]\s])/,
|
url: /^(https?:\/\/[^\s]+[^.,:;"')\]\s])/,
|
||||||
text: /^[^\0]+?(?=[\\<!\[_*`]|https?:\/\/| {2,}\n|$)/
|
text: /^[\s\S]+?(?=[\\<!\[_*`]|https?:\/\/| {2,}\n|$)/
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user