From 62248c06d388d2f16788bdc46d087ae809f77a11 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sat, 15 Oct 2011 14:03:13 +0000 Subject: Don't need to rescan authority if there was no scheme. Bring documentation back into sync with code. Make pre-authority slash skipping more robust. svn path=/trunk/netsurf/; revision=13061 --- utils/nsurl.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) (limited to 'utils/nsurl.c') diff --git a/utils/nsurl.c b/utils/nsurl.c index 6b309f1f5..bb7b5068e 100644 --- a/utils/nsurl.c +++ b/utils/nsurl.c @@ -263,8 +263,6 @@ static void nsurl__get_string_markers(const char const *url_s, } else { /* Not found a scheme */ - pos = url_s + marker.start; - if (joining == false) { /* Assuming no scheme == http */ is_http = true; @@ -274,27 +272,31 @@ static void nsurl__get_string_markers(const char const *url_s, /* Get authority * - * If this is a relative url that is to be joined onto a base URL, we - * require two slashes to be certain we correctly handle a missing - * authority. + * Two slashes always indicates the start of an authority. * - * If this URL is not getting joined, we are less strict in the case of - * http(s) and will accept any number of slashes, including 0. + * We are more relaxed in the case of http: + * a. when joining, one or more slashes indicates start of authority + * b. when not joining, we assume authority if no scheme was present */ if ((*pos == '/' && *(pos + 1) == '/') || - (is_http && ((joining && (*pos == '/')) || - joining == false))) { + (is_http && ((joining && *pos == '/') || + (joining == false && + marker.scheme_end != marker.start)))) { + /* Skip over leading slashes */ - if (is_http == false) { - if (*pos == '/') pos++; - if (*pos == '/') pos++; - } else { - while (*pos == '/') - pos++; - } + if (*pos == '/') { + if (is_http == false) { + if (*pos == '/') pos++; + if (*pos == '/') pos++; + } else { + while (*pos == '/') + pos++; + } - marker.authority = marker.colon_first = marker.at = - marker.colon_last = marker.path = pos - url_s; + marker.authority = marker.colon_first = marker.at = + marker.colon_last = marker.path = + pos - url_s; + } /* Need to get (or complete) the authority */ while (*pos != '\0') { -- cgit v1.2.3