Skip to content

Commit

Permalink
Ruby: Fixed exponential backtracking (#2225)
Browse files Browse the repository at this point in the history
This fixes the exponential backtracking in one of Ruby's regex patterns.
  • Loading branch information
RunDevelopment authored Feb 21, 2020
1 parent 6124c97 commit c5de5aa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions components/prism-ruby.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
* Original by Samuel Flores
*
* Adds the following new token classes:
* constant, builtin, variable, symbol, regex
* constant, builtin, variable, symbol, regex
*/
(function(Prism) {
(function (Prism) {
Prism.languages.ruby = Prism.languages.extend('clike', {
'comment': [
/#.*/,
Expand All @@ -13,13 +13,13 @@
greedy: true
}
],
'class-name': {
pattern: /(\b(?:class)\s+|\bcatch\s+\()[\w.\\]+/i,
lookbehind: true,
inside: {
'punctuation': /[.\\]/
}
},
'class-name': {
pattern: /(\b(?:class)\s+|\bcatch\s+\()[\w.\\]+/i,
lookbehind: true,
inside: {
'punctuation': /[.\\]/
}
},
'keyword': /\b(?:alias|and|BEGIN|begin|break|case|class|def|define_method|defined|do|each|else|elsif|END|end|ensure|extend|for|if|in|include|module|new|next|nil|not|or|prepend|protected|private|public|raise|redo|require|rescue|retry|return|self|super|then|throw|undef|unless|until|when|while|yield)\b/
});

Expand Down Expand Up @@ -75,7 +75,7 @@
}
},
{
pattern: /(^|[^/])\/(?!\/)(?:\[.+?]|\\.|[^/\\\r\n])+\/[gim]{0,3}(?=\s*(?:$|[\r\n,.;})]))/,
pattern: /(^|[^/])\/(?!\/)(?:\[[^\r\n\]]+\]|\\.|[^[/\\\r\n])+\/[gim]{0,3}(?=\s*(?:$|[\r\n,.;})]))/,
lookbehind: true,
greedy: true
}
Expand Down
2 changes: 1 addition & 1 deletion components/prism-ruby.min.js

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

0 comments on commit c5de5aa

Please sign in to comment.