[evolution-data-server/gnome-3-38] evo-I#1070 - Improve URL scanner (detect angle brackets)



commit ac86e71aefdd191a514916895d4392c512907dd9
Author: Milan Crha <mcrha redhat com>
Date:   Wed Sep 16 11:50:21 2020 +0200

    evo-I#1070 - Improve URL scanner (detect angle brackets)
    
    Related to https://gitlab.gnome.org/GNOME/evolution/-/issues/1070

 src/camel/camel-url-scanner.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/src/camel/camel-url-scanner.c b/src/camel/camel-url-scanner.c
index f18536053..185f386ad 100644
--- a/src/camel/camel-url-scanner.c
+++ b/src/camel/camel-url-scanner.c
@@ -226,11 +226,19 @@ camel_url_pattern_end (const gchar *in,
                gint start_pos, end_pos;
 
                if (g_match_info_fetch_pos (match_info, 0, &start_pos, &end_pos) && start_pos == 0 && end_pos 
0 && end_pos <= inend - pos) {
-                       const gchar *inptr = pos + end_pos;
+                       const gchar *inptr = pos + end_pos, *ptr;
 
-                       success = TRUE;
+                       /* Stop on the angle brackets, which cannot be part of the URL (see RFC 3986 Appendix 
C) */
+                       for (ptr = pos; ptr < inptr; ptr++) {
+                               if (*ptr == '<' || *ptr == '>') {
+                                       inptr = ptr;
+                                       break;
+                               }
+                       }
+
+                       success = inptr > pos;
 
-                       if (remove_trailing_bad_chars) {
+                       if (remove_trailing_bad_chars && success) {
                                /* urls are extremely unlikely to end with any
                                 * punctuation, so strip any trailing
                                 * punctuation off. Also strip off any closing
@@ -249,7 +257,6 @@ camel_url_pattern_end (const gchar *in,
 
                                        if (open_bracket != 0) {
                                                gint n_opened = 0, n_closed = 0;
-                                               const gchar *ptr;
 
                                                for (ptr = pos; ptr < inptr; ptr++) {
                                                        if (*ptr == open_bracket)


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