[Spice-devel] [PATCH spice-gtk] Correctly parse RFC-conform URIs separating the host and the arguments by a '/'

Tiziano Müller tiziano.mueller at stepping-stone.ch
Tue Nov 1 01:49:28 PDT 2011


Little patch to make spice-gtk accept RFC-conform URLs of the form "spice://host/?port=5901".

I didn't add '/' to the list of the other characters to ignore (?;&) by intention since
an URL like spice://host/?port=5901/somotherstuff should not be valid, resp. the password
may contain '/' because the string is already unescaped at that point.

Unfortunately glib does not seem to have functions to 'explode' an URI which would be really helpful.

Cheers,
Tiziano

---
 gtk/spice-session.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/gtk/spice-session.c b/gtk/spice-session.c
index 3ce80d5..90e0318 100644
--- a/gtk/spice-session.c
+++ b/gtk/spice-session.c
@@ -290,6 +290,10 @@ static int spice_uri_parse(SpiceSession *session, const char *original_uri)
     if (sscanf(uri, "spice://%127[-.0-9a-zA-Z]%n", host, &len) != 1)
         goto fail;
     pos += len;
+
+    if (uri[pos] == '/')
+        pos++;
+
     for (;;) {
         if (uri[pos] == '?' || uri[pos] == ';' || uri[pos] == '&') {
             pos++;
-- 
1.7.7

-- 
stepping stone GmbH
Neufeldstrasse 9
CH-3012 Bern

Telefon: +41 31 332 53 63
www.stepping-stone.ch
tiziano.mueller at stepping-stone.ch



More information about the Spice-devel mailing list