[Spice-devel] [PATCH v2 spice-gtk 2/3] spice-session: support uri with colon
Marc-André Lureau
marcandre.lureau at gmail.com
Thu Jan 5 04:07:07 PST 2012
On Tue, Jan 3, 2012 at 5:52 PM, Alon Levy <alevy at redhat.com> wrote:
> With this patch if you use:
> spice://<host>:<port>
>
> You will get a warning (g_warning) and it will be treated the same as
> spice://<host>?port=<port>
>
If we introduce this on purpose, we really shouldn't warn about it.
> You will also get a warning for the following double port definition:
> spice://<host>:<port>?port=<port>
> ---
> gtk/spice-session.c | 18 ++++++++++++++++--
> 1 files changed, 16 insertions(+), 2 deletions(-)
>
> diff --git a/gtk/spice-session.c b/gtk/spice-session.c
> index b640e06..9ac543d 100644
> --- a/gtk/spice-session.c
> +++ b/gtk/spice-session.c
> @@ -266,8 +266,22 @@ static int spice_uri_parse(SpiceSession *session,
> const char *original_uri)
> if (uri[pos] == 0) {
> break;
> }
> - if (sscanf(uri + pos, "%31[-a-zA-Z0-9]=%127[^;&]%n", key, value,
> &len) != 2)
> - goto fail;
> + if (uri[pos] == ':') {
> + g_warning("usage of colon in spice URI parsing. Treating as a
> port (?port=)");
>
if you'd like to keep it, you could turn it into a SPICE_DEBUG?
> + if (punctuation++) {
> + g_warning("colon seen after a previous punctuation
> (?;&:)");
> + goto fail;
> + }
> + pos++;
> + if (sscanf(uri + pos, "%127[0-9]%n", value, &len) != 1)
>
I guess %5 would be enough.. even if we are far from building the perfect
uri parser ;)
> + goto fail;
> + port = g_strdup(value);
> + pos += len;
> + continue;
> + } else {
> + if (sscanf(uri + pos, "%31[-a-zA-Z0-9]=%127[^;&]%n", key,
> value, &len) != 2)
> + goto fail;
> + }
> pos += len;
> target_key = NULL;
> if (g_str_equal(key, "port")) {
>
>
ack otherwise
--
Marc-André Lureau
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20120105/02776224/attachment-0001.htm>
More information about the Spice-devel
mailing list