[Spice-devel] [spice-gtk 2/5] session: Lookup URI query part before path part
Christophe Fergeau
cfergeau at redhat.com
Tue Jun 4 07:19:11 PDT 2013
When parsing an URI, spice_uri_parse currently first looks up for
'/' to detect the 'path' part of the URI
(http://foo.example.com/some/path) and then the query part (starting
with '&' is looked up).
However, this does not work as expected when the host name is not
followed by a path, but the query part contains a path:
http://foo.example.com&my_param=/some/path
This commit starts inverts the path detection/query detection step,
it first detects the beginning of the query part and splits it out,
and then looks for '/' in the part which came before the query part.
---
gtk/spice-session.c | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
diff --git a/gtk/spice-session.c b/gtk/spice-session.c
index 8cb2d39..83b91db 100644
--- a/gtk/spice-session.c
+++ b/gtk/spice-session.c
@@ -281,7 +281,6 @@ spice_session_finalize(GObject *gobject)
#define URI_SCHEME_SPICE "spice://"
#define URI_QUERY_START ";?"
-#define URI_QUERY_SEP ";&"
static int spice_uri_create(SpiceSession *session, char *dest, int len)
{
@@ -322,24 +321,20 @@ static int spice_uri_parse(SpiceSession *session, const char *original_uri)
goto fail;
}
authority = uri + strlen(URI_SCHEME_SPICE);
+
+ query = authority + strcspn(authority, URI_QUERY_START);
+ if (query[0]) {
+ query[0] = '\0';
+ query++;
+ }
+
path = strchr(authority, '/');
if (path) {
path[0] = '\0';
path++;
}
- if (path) {
- size_t prefix = strcspn(path, URI_QUERY_START);
- query = path + prefix;
- } else {
- size_t prefix = strcspn(authority, URI_QUERY_START);
- query = authority + prefix;
- }
- if (query && query[0]) {
- query[0] = '\0';
- query++;
- }
/* Now process the individual parts */
--
1.8.2.1
More information about the Spice-devel
mailing list