From 4460f92727dc024bf89407c94bf899b914823a67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sun, 31 Mar 2024 13:57:32 +0200 Subject: [PATCH] relay: stop URL address before the first question mark if colon is not found (issue #2066) --- src/plugins/relay/relay-remote.c | 3 +++ tests/unit/plugins/relay/test-relay-remote.cpp | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/plugins/relay/relay-remote.c b/src/plugins/relay/relay-remote.c index 15dc42b50..f7d9becb4 100644 --- a/src/plugins/relay/relay-remote.c +++ b/src/plugins/relay/relay-remote.c @@ -252,6 +252,9 @@ relay_remote_get_address (const char *url) return NULL; pos = strchr (ptr_start, ':'); + if (!pos) + pos = strchr (ptr_start, '?'); + return (pos) ? weechat_strndup (ptr_start, pos - ptr_start) : strdup (ptr_start); } diff --git a/tests/unit/plugins/relay/test-relay-remote.cpp b/tests/unit/plugins/relay/test-relay-remote.cpp index aab1f032f..e2c7816a8 100644 --- a/tests/unit/plugins/relay/test-relay-remote.cpp +++ b/tests/unit/plugins/relay/test-relay-remote.cpp @@ -127,6 +127,8 @@ TEST(RelayRemote, GetAddress) STRCMP_EQUAL("example.com", relay_remote_get_address ("https://example.com")); STRCMP_EQUAL("example.com", relay_remote_get_address ("https://example.com:8000")); STRCMP_EQUAL("example.com", relay_remote_get_address ("https://example.com:8000/")); + STRCMP_EQUAL("example.com", relay_remote_get_address ("https://example.com:8000/?option=1")); + STRCMP_EQUAL("example.com", relay_remote_get_address ("https://example.com?option=1")); } /*