Fix insanely catastrophic backtracking when typing a link with a #hash and then “return” #

This change makes this part of the regexp “greedy and posessive”, meaning that if the regexp reaches the `$` end-of-string qualifier and it’s not the end of the string, it can’t go back and try to change the way it allocated characters to the regexp to make it work (infinitely.)
This commit is contained in:
Ben Gotow 2019-07-22 11:12:46 -05:00
parent 78268432c5
commit 1d2163c29a

View file

@ -167,7 +167,7 @@ const RegExpUtils = {
// optionally followed by: a query string and/or a #location // optionally followed by: a query string and/or a #location
// (last character must not be puncation, hence two groups) // (last character must not be puncation, hence two groups)
"(?:(\\?[\\-\\+=&;%@\\.\\w_\\#]*[\\#\\-\\+=&;%@\\w_\\/]+)?#?(?:['\\$\\&\\(\\)\\*\\+,;=\\.\\!\\/\\\\\\w%-?]*[\\/\\\\\\w]+)?)?", "(?:(\\?[\\-\\+=&;%@\\.\\w_\\#]*[\\#\\-\\+=&;%@\\w_\\/]+)?#?(?:['\\$\\&\\(\\)\\*\\+,;=\\.\\!\\/\\\\\\w%-?]*[\\/\\\\\\w]+)?)?",
')?', ')?+',
')', ')',
]; ];
if (matchStartOfString) { if (matchStartOfString) {