-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use correct options in specs #1511
Conversation
I also agree with @Feder1co5oave that we should remove the |
hr: /^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/, | ||
heading: /^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/, | ||
nptable: noop, | ||
heading: /^ {0,3}(#{1,6}) +([^\n]*?)(?: +#+)? *(?:\n+|$)/, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks OK
table: noop, | ||
lheading: /^([^\n]+)\n {0,3}(=|-){2,} *(?:\n+|$)/, | ||
paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading| {0,3}>|<\/?(?:tag)(?: +|\n|\/?>)|<(?:script|pre|style|!--))[^\n]+)*)/, | ||
lheading: /^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
lheading: /^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/, | ||
// regex template, placeholders will be replaced according to different paragraph | ||
// interruption rules of commonmark and the original markdown spec: | ||
_paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html)[^\n]+)*)/, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
fences: /^ {0,3}(`{3,}|~{3,})([^`\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/, | ||
paragraph: /^/, | ||
heading: /^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/ | ||
nptable: /^ *([^|\n ].*\|.*)\n *([-:]+ *\|[-| :]*)(?:\n((?:.*[^>\n ].*(?:\n|$))*)\n*|$)/, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super-linear.
- The construct
.*\|.*
can be exploited through a run of|||...|
. Can we replace with[^|]*|[^|]*
? - I believe the same problem applies later in the
(?:.*[^>\n ].*
section.
paragraph: /^/, | ||
heading: /^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/ | ||
nptable: /^ *([^|\n ].*\|.*)\n *([-:]+ *\|[-| :]*)(?:\n((?:.*[^>\n ].*(?:\n|$))*)\n*|$)/, | ||
table: /^ *\|(.+)\n *\|?( *[-:]+[-| :]*)(?:\n((?: *[^>\n ].*(?:\n|$))*)\n*|$)/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same genre of problem as the nptable
.
if (/^ *\|(.+)\n *\|?( *[-:]+[-| :]*)(?:\n((?: *[^>\n ].*(?:\n|$))*)\n*|$)/.exec(' | \n' + ' '.repeat(50000))) {
console.log('match');
}
(Note, here and elsewhere I'm just checking regexes, not full exploitability).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To discuss: super-linear regexes.
Not sure if the regexes are new or just re-org'd (in which case we should note them but they shouldn't block this PR).
I updated the
The only changed regexes were |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM then
I did remove the |
Marked version: master
Description
I am trying to implement the changes from @Feder1co5oave in #1407
gfm: false
gfm: true
pedantic: true
heading
,lheading
, andparagraph
These changes improve CommonMark compliance significantly:
Issues
closes #1407
fixes #1510
Contributor
Committer
In most cases, this should be a different person than the contributor.