[Spice-devel] [PATCH spice-gtk] proxy: remove trailing slash from proxy URL
Marc-André Lureau
marcandre.lureau at gmail.com
Tue Jun 18 07:58:28 PDT 2013
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
---
gtk/spice-proxy.c | 16 ++++++++++++++--
1 file 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;
}
--
1.8.3.rc1.49.g8d97506
More information about the Spice-devel
mailing list