[gnome-shell] util: Handle trailing LTR/RTL markers in URLs



commit 252e6949790f95d14bca14ff4e38fa35571f3a01
Author: Florian Müllner <fmuellner gnome org>
Date:   Sat Sep 14 00:03:02 2019 +0200

    util: Handle trailing LTR/RTL markers in URLs
    
    Some electron apps apparently spread those generously over their
    notification text, so may sure to not include them accidentally
    in URLs.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/issues/1614

 js/misc/util.js   | 2 +-
 tests/unit/url.js | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/js/misc/util.js b/js/misc/util.js
index 87a6c12252..db3742eb3d 100644
--- a/js/misc/util.js
+++ b/js/misc/util.js
@@ -14,7 +14,7 @@ var SCROLL_TIME = 100;
 // http://daringfireball.net/2010/07/improved_regex_for_matching_urls
 const _balancedParens = '\\([^\\s()<>]+\\)';
 const _leadingJunk = '[\\s`(\\[{\'\\"<\u00AB\u201C\u2018]';
-const _notTrailingJunk = '[^\\s`!()\\[\\]{};:\'\\".,<>?\u00AB\u00BB\u201C\u201D\u2018\u2019]';
+const _notTrailingJunk = 
'[^\\s`!()\\[\\]{};:\'\\".,<>?\u00AB\u00BB\u200E\u200F\u201C\u201D\u2018\u2019\u202A\u202C]';
 
 const _urlRegexp = new RegExp(
     `(^|${_leadingJunk})` +
diff --git a/tests/unit/url.js b/tests/unit/url.js
index 158316bb41..84aecc95f4 100644
--- a/tests/unit/url.js
+++ b/tests/unit/url.js
@@ -42,6 +42,8 @@ const tests = [
       output: [ { url: 'https://www.gnome.org/(some_url,_with_very_unusual_characters)', pos: 0 } ] },
     { input: 'https://www.gnome.org/(some_url_with_unbalanced_parenthesis',
       output: [ { url: 'https://www.gnome.org/', pos: 0 } ] },
+    { input: 'https://www.gnome.org/‎ plus trailing junk',
+      output: [ { url: 'https://www.gnome.org/', pos: 0 } ] },
 
     { input: 'Visit http://www.gnome.org/ and http://developer.gnome.org',
       output: [ { url: 'http://www.gnome.org/', pos: 6 },


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]