[Spice-devel] [PATCH v2 spice-gtk 2/3] spice-session: support uri with colon
Alon Levy
alevy at redhat.com
Thu Jan 5 04:11:44 PST 2012
On Thu, Jan 05, 2012 at 01:07:07PM +0100, Marc-André Lureau wrote:
> 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.
ok, I didn't really decide if we want it supported or just working but
deprecated from the start. I guess we'll just call it supported. (it is
the most similar to other forms of urls, i.e. http).
Fixing.
>
>
> > 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?
No, I think I'll just drop it.
>
>
> > + 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 ;)
Just copied what was used below. It gives 127 chars to any parameter
(tls-port, port, password) and of course you are right about 10000 >
65525 > 1000
I'll fix.
>
>
> > + 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
More information about the Spice-devel
mailing list