diff options
| author | Milan Crha <mcrha@redhat.com> | 2020-09-16 11:50:21 +0200 |
|---|---|---|
| committer | Milan Crha <mcrha@redhat.com> | 2020-09-16 11:50:21 +0200 |
| commit | 19e14dd4b18aefdd29f77704923015636677e173 (patch) | |
| tree | 896539d8f31ebcf091bcae61e6491f005556fd86 | |
| parent | 0106e0ee6fedc0f107f93fe43abe05a7e1ade6bf (diff) | |
| download | evolution-data-server-19e14dd4b18aefdd29f77704923015636677e173.tar.gz | |
evo-I#1070 - Improve URL scanner (detect angle brackets)
Related to https://gitlab.gnome.org/GNOME/evolution/-/issues/1070
| -rw-r--r-- | src/camel/camel-url-scanner.c | 15 |
1 files 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) |
