diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2013-06-18 16:52:30 +0200 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2013-06-21 16:40:49 +0200 |
commit | 1c2a1231c6586b7c78c15823739480771a8861c7 (patch) | |
tree | ea576933a649e48124dfaedef2562b2cd8fda332 | |
parent | 5f67178c9602ed43f83f35a6d3097eb137244493 (diff) |
proxy: remove trailing slash from proxy URL
Apparently, trailing slash are common for proxy URI. Is there a
specification for these kind of URI?
(I cry that we don't have GUri yet to handle parsing... gbo#489862)
Fixes:
https://bugzilla.redhat.com/show_bug.cgi?id=975472
-rw-r--r-- | gtk/spice-proxy.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/gtk/spice-proxy.c b/gtk/spice-proxy.c index 55c9023..bc4037e 100644 --- a/gtk/spice-proxy.c +++ b/gtk/spice-proxy.c @@ -48,18 +48,29 @@ SpiceProxy* spice_proxy_new(void) } G_GNUC_INTERNAL -gboolean spice_proxy_parse(SpiceProxy *self, const gchar *uri, GError **error) +gboolean spice_proxy_parse(SpiceProxy *self, const gchar *proxyuri, GError **error) { + gchar *dup, *uri; gboolean success = FALSE; + size_t len; g_return_val_if_fail(self != NULL, FALSE); - g_return_val_if_fail(uri != NULL, FALSE); + g_return_val_if_fail(proxyuri != NULL, FALSE); + uri = dup = g_strdup(proxyuri); /* FIXME: use GUri when it is ready... only support http atm */ /* the code is voluntarily not parsing thoroughly the uri */ if (g_ascii_strncasecmp("http://", uri, 7) == 0) uri += 7; + /* remove trailing slash */ + len = strlen(uri); + for (; len > 0; len--) + if (uri[len-1] == '/') + uri[len-1] = '\0'; + else + break; + spice_proxy_set_protocol(self, "http"); spice_proxy_set_port(self, 3128); @@ -90,6 +101,7 @@ gboolean spice_proxy_parse(SpiceProxy *self, const gchar *uri, GError **error) success = TRUE; end: + g_free(dup); g_strfreev(proxyv); return success; } |