[evolution] Bug 744009 - URL detection in composer is often incorrect: does not highlight entire URL, but *does*



commit aa30ccde7be283b78b4d32a896f45874a5da98c1
Author: Tomas Popela <tpopela redhat com>
Date:   Fri Mar 13 19:32:14 2015 +0100

    Bug 744009 - URL detection in composer is often incorrect: does not highlight entire URL, but *does* 
highlight subsequent words that aren't part of the URL
    
    Rework the regular expression that is used for detecting links.
    Simplify it as Evolution is not URL validator, but we are giving
    a possibility to user to try the URL.

 e-util/e-html-editor-view.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)
---
diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c
index d7902c5..01aeb65 100644
--- a/e-util/e-html-editor-view.c
+++ b/e-util/e-html-editor-view.c
@@ -38,12 +38,9 @@
 #define UNICODE_ZERO_WIDTH_SPACE "\xe2\x80\x8b"
 #define UNICODE_NBSP "\xc2\xa0"
 
-#define URL_PATTERN \
-       "((([A-Za-z]{3,9}:(?:\\/\\/)?)(?:[\\-;:&=\\+\\$,\\w]+@)?" \
-       "[A-Za-z0-9\\.\\-]+|(?:www\\.|[\\-;:&=\\+\\$,\\w]+@)" \
-       "[A-Za-z0-9\\.\\-]+)((?:\\/[\\+~%\\/\\.\\w\\-]*)?\\?" \
-       "?(?:[\\-\\+=&;% \\ \\w]*)#?(?:[\\.\\!\\/\\\\w]*))?)"
-
+/* stephenhay from https://mathiasbynens.be/demo/url-regex */
+#define URL_PROTOCOLS "news|telnet|nntp|file|https?|s?ftp||webcal|localhost"
+#define URL_PATTERN "((((" URL_PROTOCOLS ")\\:\\/\\/)|(www\\.|ftp\\.))[^\\s\\/\\$\\.\\?#].[^\\s]*)"
 #define URL_PATTERN_SPACE URL_PATTERN "\\s"
 
 /* http://www.w3.org/TR/html5/forms.html#valid-e-mail-address */


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