[polari/wip/fmuellner/fix-regex-lockup: 11/11] utils: Simplify URL regex to only support one layer of parentheses
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/fmuellner/fix-regex-lockup: 11/11] utils: Simplify URL regex to only support one layer of parentheses
- Date: Sat, 3 Mar 2018 15:43:50 +0000 (UTC)
commit 8d8ad796f2e6cc2687e29f205d79acba10a171d3
Author: Florian Müllner <fmuellner gnome org>
Date: Sat Feb 24 23:52:39 2018 +0100
utils: Simplify URL regex to only support one layer of parentheses
The author of the original URL-matching regex warns[0] that the pattern may
cause certain regex engines to lock up with certain input, namely patterns
that contain parentheses. It turns out SpiderMonkey is affected, but rather
than switching to the author's improved version (that is still crazy), sim-
plify the pattern a bit by removing support for nested parentheses in URLs.
Even a single pair of parentheses is extremely rare, so this is unlikely to
make a noticeable difference (other than not locking up SpiderMonkey of
course) ...
[0] http://daringfireball.net/2010/07/improved_regex_for_matching_urls
https://gitlab.gnome.org/GNOME/polari/issues/46
src/utils.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/src/utils.js b/src/utils.js
index 6c381a0..ea1f75e 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -49,7 +49,7 @@ const MAX_PASTE_TITLE_LENGTH = 25;
const IMGUR_CLIENT_ID = '4109e59177ec95e';
// http://daringfireball.net/2010/07/improved_regex_for_matching_urls
-const _balancedParens = '\\((?:[^\\s()<>]+|(?:\\(?:[^\\s()<>]+\\)))*\\)';
+const _balancedParens = '\\([^\\s()<>]+\\)';
const _leadingJunk = '[\\s`(\\[{\'\\"<\u00AB\u201C\u2018]';
const _notTrailingJunk = '[^\\s`!()\\[\\]{};:\'\\".,<>?\u00AB\u00BB\u201C\u201D\u2018\u2019]';
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]