Re: [PATCH spice-gtk 04/14] proxy: parse user and pass from uri

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Feb 12, 2014 at 11:19:02AM +0100, Marc-André Lureau wrote:
> From: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>
> 
> ---
>  gtk/spice-proxy.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/gtk/spice-proxy.c b/gtk/spice-proxy.c
> index 7711e83..35eec67 100644
> --- a/gtk/spice-proxy.c
> +++ b/gtk/spice-proxy.c
> @@ -19,6 +19,7 @@
>  #include <stdlib.h>
>  #include <string.h>
>  
> +#include "glib-compat.h"
>  #include "spice-client.h"
>  #include "spice-proxy.h"
>  
> @@ -78,6 +79,18 @@ gboolean spice_proxy_parse(SpiceProxy *self, const gchar *proxyuri, GError **err
>      spice_proxy_set_protocol(self, "http");
>      spice_proxy_set_port(self, 3128);
>  
> +    /* yes, that parser is bad, we need GUri... */
> +    if (strstr(uri, "@")) {
> +        gchar *saveptr, *saveptr2;
> +        gchar *next = strstr(uri, "@") + 1;

The strstr() call could probably be done only once, but it's fine enough
like this.

ACK.

Christophe

> +        gchar *auth = strtok_r(uri, "@", &saveptr);
> +        const gchar *user = strtok_r(auth, ":", &saveptr2);
> +        const gchar *pass = strtok_r(NULL, ":", &saveptr2);
> +        spice_proxy_set_user(self, user);
> +        spice_proxy_set_password(self, pass);
> +        uri = next;
> +    }
> +
>      /* max 2 parts, host:port */
>      gchar **proxyv = g_strsplit(uri, ":", 2);
>      const gchar *proxy_port = NULL;
> -- 
> 1.8.4.2
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel@xxxxxxxxxxxxxxxxxxxxx
> http://lists.freedesktop.org/mailman/listinfo/spice-devel

Attachment: pgpeCLFSfZ7_i.pgp
Description: PGP signature

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]