[Spice-devel] [PATCH spice-gtk] proxy: remove trailing slash from proxy URL
Christophe Fergeau
cfergeau at redhat.com
Wed Jun 19 03:00:24 PDT 2013
On Tue, Jun 18, 2013 at 04:58:28PM +0200, Marc-André Lureau wrote:
> 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)
Looks good, ACK
Christophe
>
> 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
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20130619/58ccd184/attachment-0001.pgp>
More information about the Spice-devel
mailing list