From: Daniel Carl <danielcarl@gmx.de>
Date: Fri, 17 Nov 2017 08:39:22 +0000 (+0100)
Subject: Do not sanitize uri if this is no needed.
X-Git-Url: https://git.owens.tech/projects.html/projects.html/git?a=commitdiff_plain;h=43f73383a4b9eb041464146759249dde6654edd5;p=vimb.git

Do not sanitize uri if this is no needed.

Most of the time uri do not contain credentials, so don't run expensive
uri cleanup if there is not @ char in uri indicating that this might
contain at least a username and possibly also and password.
---

diff --git a/src/util.c b/src/util.c
index 8739ad5..4ea3ece 100644
--- a/src/util.c
+++ b/src/util.c
@@ -743,6 +743,12 @@ char *util_sanitize_uri(const char *uri_str)
     SoupURI *uri;
     char *sanitized_uri;
 
+    /* Sanitize the uri only in case there is a @ which might be the indicator
+     * for credentials used in uri. */
+    if (!strchr(uri_str, '@')) {
+        return g_strdup(uri_str);
+    }
+
     uri = soup_uri_new(uri_str);
     sanitized_uri = soup_uri_to_string(uri, FALSE);
     soup_uri_free(uri);