[Spice-devel] [PATCH 1/3] session: accept argument in URI without value
Marc-André Lureau
mlureau at redhat.com
Fri Feb 27 07:42:35 PST 2015
ack
----- Original Message -----
> The examples below should be considered valid URIs:
>
> e.g: spice://localhost?port=5900&tls-port=
> e.g: spice://localhost?tls-port=&port=5900
>
> This patch deals with arguments with empty value;
> ---
> gtk/spice-session.c | 20 ++++++++++++++++++--
> 1 file changed, 18 insertions(+), 2 deletions(-)
>
> diff --git a/gtk/spice-session.c b/gtk/spice-session.c
> index 82ea55f..607224b 100644
> --- a/gtk/spice-session.c
> +++ b/gtk/spice-session.c
> @@ -470,10 +470,26 @@ static int spice_parse_uri(SpiceSession *session, const
> char *original_uri)
> gchar **target_key;
>
> int len;
> - if (sscanf(query, "%31[-a-zA-Z0-9]=%127[^;&]%n", key, value, &len)
> != 2) {
> - g_warning("Failed to parse URI query '%s'", query);
> + if (sscanf(query, "%31[-a-zA-Z0-9]=%n", key, &len) != 1) {
> + spice_warning("Failed to parse key in URI '%s'", query);
> goto fail;
> }
> +
> + query += len;
> + if (*query == '\0') {
> + spice_warning ("key '%s' without value", key);
> + break;
> + } else if (*query == ';' || *query == '&') {
> + /* another argument */
> + query++;
> + continue;
> + }
> +
> + if (sscanf(query, "%127[^;&]%n", value, &len) != 1) {
> + spice_warning("Failed to parse value of key '%s' in URI '%s'",
> key, query);
> + goto fail;
> + }
> +
> query += len;
> if (*query)
> query++;
> --
> 2.1.0
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
>
More information about the Spice-devel
mailing list