From 960924d570742a0dd60266ac5c083e76e9c2e128 Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Mon, 28 Aug 2023 12:58:00 +0200 Subject: [PATCH] Cut URLs before adding to automcomp at `>` First I tried with g_uri_parse() and g_uri_to_string() but then I learned that GUri validation API is only for things that are part of a proper URL. Let's cut the string at `>` since they are sometimes enclosed in `<>`. Fix https://github.com/profanity-im/profanity/issues/1877 --- src/ui/window_list.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ui/window_list.c b/src/ui/window_list.c index 4898f7a5..ce5560ef 100644 --- a/src/ui/window_list.c +++ b/src/ui/window_list.c @@ -1316,6 +1316,12 @@ wins_add_urls_ac(const ProfWin* const win, const ProfMessage* const message, con while (g_match_info_matches(match_info)) { auto_gchar gchar* word = g_match_info_fetch(match_info, 0); + // cut string at '>' from url since they are sometimes enclosed in <> + gchar* f = g_utf8_strchr(word, -1, '>'); + if (f) { + *f = '\0'; + } + if (flip) { autocomplete_add_unsorted(win->urls_ac, word, FALSE); } else {