From 195e4bcff3c4dfd3fe8bbf0df57d53ce89ca99e8 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 29 Jun 2017 12:21:09 -0400 Subject: Fix strict parsing of abolute URI schemes --- src/uri.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/uri.c') diff --git a/src/uri.c b/src/uri.c index 6b4fc07e..fcea3b62 100644 --- a/src/uri.c +++ b/src/uri.c @@ -103,16 +103,12 @@ serd_uri_string_has_scheme(const uint8_t* utf8) if (!utf8 || !is_alpha(utf8[0])) { return false; // Invalid scheme initial character, URI is relative } + for (uint8_t c; (c = *++utf8) != '\0';) { - switch (c) { - case ':': + if (!is_uri_scheme_char(c)) { + return false; + } else if (c == ':') { return true; // End of scheme - case '+': case '-': case '.': - break; // Valid scheme character, continue - default: - if (!is_alpha(c) && !is_digit(c)) { - return false; // Invalid scheme character - } } } -- cgit v1.2.1