Skip to content

Commit

Permalink
Fixed several cases of exponential backtracking (PrismJS#2268)
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment authored and quentinvernot committed Sep 11, 2020
1 parent eb8a725 commit 2812e09
Show file tree
Hide file tree
Showing 59 changed files with 122 additions and 100 deletions.
2 changes: 1 addition & 1 deletion components/prism-antlr4.js
Expand Up @@ -31,7 +31,7 @@ Prism.languages.antlr4 = {
}
},
'command': {
pattern: /(->\s*)(?:\s*(?:,\s*)?[a-z]\w*(?:\s*\([^()\r\n]*\))?)+(?=\s*;)/i,
pattern: /(->\s*)(?:\s*(?:,\s*)?\b[a-z]\w*(?:\s*\([^()\r\n]*\))?)+(?=\s*;)/i,
lookbehind: true,
inside: {
'function': /\b\w+(?=\s*(?:[,(]|$))/,
Expand Down
2 changes: 1 addition & 1 deletion components/prism-antlr4.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions components/prism-applescript.js
@@ -1,7 +1,7 @@
Prism.languages.applescript = {
'comment': [
// Allow one level of nesting
/\(\*(?:\(\*[\s\S]*?\*\)|[\s\S])*?\*\)/,
/\(\*(?:\(\*(?:[^*]|\*(?!\)))*\*\)|(?!\(\*)[\s\S])*?\*\)/,
/--.+/,
/#.+/
],
Expand All @@ -17,4 +17,4 @@ Prism.languages.applescript = {
alias: 'builtin'
},
'punctuation': /[{}():,¬«»《》]/
};
};
2 changes: 1 addition & 1 deletion components/prism-applescript.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/prism-asciidoc.js
Expand Up @@ -149,7 +149,7 @@
Those do not have the restrictions of the constrained quotes.
They are, in order: __emphasis__, **strong**, ++monospace++, +++passthrough+++, ##unquoted##, $$passthrough$$, ~subscript~, ^superscript^, {attribute-reference}, [[anchor]], [[[bibliography anchor]]], <<xref>>, (((indexes))) and ((indexes))
*/
pattern: /(^|[^\\])(?:(?:\B\[(?:[^\]\\"]|(["'])(?:(?!\2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?\)\)))/m,
lookbehind: true,
inside: {
'attributes': attributes,
Expand Down
2 changes: 1 addition & 1 deletion components/prism-asciidoc.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/prism-c.js
Expand Up @@ -23,7 +23,7 @@ Prism.languages.insertBefore('c', 'string', {
inside: {
// highlight the path of the include statement as a string
'string': {
pattern: /(#\s*include\s*)(?:<.+?>|("|')(?:\\?.)+?\2)/,
pattern: /(#\s*include\s*)(?:<.+?>|(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2)/,
lookbehind: true
},
// highlight macro directives as keywords
Expand Down

0 comments on commit 2812e09

Please sign in to comment.