[gnome-shell] util: Fix regex used to match for URLs
- From: Maxim Ermilov <mermilov src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] util: Fix regex used to match for URLs
- Date: Wed, 19 Jan 2011 02:09:46 +0000 (UTC)
commit 255d4634a9d6f3506f4c85299795bd056c4a8860
Author: Maxim Ermilov <zaspire rambler ru>
Date: Wed Jan 19 05:06:53 2011 +0300
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 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/js/misc/util.js b/js/misc/util.js
index db5dc01..fc515eb 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]