diff options
author | Dan Winship <danw@gnome.org> | 2013-07-13 11:55:00 -0400 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2013-07-13 11:58:04 -0400 |
commit | 2e436f5c75fcff49518a33eee6429a23f556ec6d (patch) | |
tree | e0f814abdc28940aa2b57da2c9021ea5063852e3 | |
parent | 74f27b8305cfbcf9324a07bea93829237c86e687 (diff) | |
download | libsoup-2e436f5c75fcff49518a33eee6429a23f556ec6d.tar.gz |
soup-uri: fix URI scheme parsing
The URI grammar allows a scheme to have digits in it after the first
character, and doesn't allow [.+-] in the first character.
https://bugzilla.gnome.org/show_bug.cgi?id=703776
-rw-r--r-- | libsoup/soup-uri.c | 7 | ||||
-rw-r--r-- | tests/uri-parsing.c | 16 |
2 files changed, 21 insertions, 2 deletions
diff --git a/libsoup/soup-uri.c b/libsoup/soup-uri.c index b9ff93fe..16098f69 100644 --- a/libsoup/soup-uri.c +++ b/libsoup/soup-uri.c @@ -263,10 +263,13 @@ soup_uri_new_with_base (SoupURI *base, const char *uri_string) end = hash; } - /* Find scheme: initial [a-z+.-]* substring until ":" */ + /* Find scheme */ p = uri_string; while (p < end && (g_ascii_isalpha (*p) || - *p == '.' || *p == '+' || *p == '-')) + (p > uri_string && (g_ascii_isdigit (*p) || + *p == '.' || + *p == '+' || + *p == '-')))) p++; if (p > uri_string && *p == ':') { diff --git a/tests/uri-parsing.c b/tests/uri-parsing.c index 892ee2b9..d1bba4e1 100644 --- a/tests/uri-parsing.c +++ b/tests/uri-parsing.c @@ -128,6 +128,22 @@ static struct { { "http://host/keep%00nuls", "http://host/keep%00nuls", { "http", NULL, NULL, "host", 80, "/keep%00nuls", NULL, NULL } }, + + /* Bug 703776; scheme parsing */ + { "foo0://host/path", "foo0://host/path", + { "foo0", NULL, NULL, "host", 0, "/path", NULL, NULL } }, + { "f0.o://host/path", "f0.o://host/path", + { "f0.o", NULL, NULL, "host", 0, "/path", NULL, NULL } }, + { "http++://host/path", "http++://host/path", + { "http++", NULL, NULL, "host", 0, "/path", NULL, NULL } }, + { "http-ish://host/path", "http-ish://host/path", + { "http-ish", NULL, NULL, "host", 0, "/path", NULL, NULL } }, + { "99http://host/path", NULL, + { NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL } }, + { ".http://host/path", NULL, + { NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL } }, + { "+http://host/path", NULL, + { NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL } }, }; static int num_abs_tests = G_N_ELEMENTS(abs_tests); |