From 255d4634a9d6f3506f4c85299795bd056c4a8860 Mon Sep 17 00:00:00 2001 From: Maxim Ermilov <zaspire@rambler.ru> Date: Wed, 19 Jan 2011 05:06:53 +0300 Subject: [PATCH] util: Fix regex used to match for URLs Commit a65a0f03d49 changed the literal RegExp to a string-based RegExp(). As backslashes are treated specially inside strings, translating an expression as /\s/ to '\s' results in a faulty regex of /s/, so escape backslashes where necessary. https://bugzilla.gnome.org/show_bug.cgi?id=639914 --- js/misc/util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/misc/util.js b/js/misc/util.js index db5dc01c6..fc515eb7b 100644 --- a/js/misc/util.js +++ b/js/misc/util.js @@ -12,7 +12,7 @@ const Gettext = imports.gettext.domain('gnome-shell'); const _ = Gettext.gettext; /* http://daringfireball.net/2010/07/improved_regex_for_matching_urls */ -const _urlRegexp = new RegExp('\b(([a-z][\w-]+:(/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)([^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:\'".,<>?«»“”‘’]))', 'gi'); +const _urlRegexp = new RegExp('\\b(([a-z][\\w-]+:(/{1,3}|[a-z0-9%])|www\\d{0,3}[.]|[a-z0-9.\\-]+[.][a-z]{2,4}/)([^\\s()<>]+|\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\))+(\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\)|[^\\s`!()\\[\\]{};:\'\\".,<>?«»“”‘’]))', 'gi'); // findUrls: // @str: string to find URLs in