[Spice-devel] [PATCH v2 spice-gtk 2/3] spice-session: support uri with colon
Alon Levy
alevy at redhat.com
Tue Jan 3 08:52:45 PST 2012
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>
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 (punctuation++) {
+ g_warning("colon seen after a previous punctuation (?;&:)");
+ goto fail;
+ }
+ pos++;
+ if (sscanf(uri + pos, "%127[0-9]%n", value, &len) != 1)
+ 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")) {
--
1.7.8.1
More information about the Spice-devel
mailing list