diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2011-10-06 11:53:23 +0000 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2011-10-06 11:53:23 +0000 |
commit | fd5ad500c5fc128549ff4dd55a0a7e611e482ce1 (patch) | |
tree | 80211fa5f43bfd90046f4e5d5d3b953c0e1829a4 /utils/nsurl.c | |
parent | 65943b7a674a0e8b22190d6afe66015b006b88f9 (diff) | |
download | netsurf-fd5ad500c5fc128549ff4dd55a0a7e611e482ce1.tar.gz netsurf-fd5ad500c5fc128549ff4dd55a0a7e611e482ce1.tar.bz2 |
Only need to cope with trailing whitespace if it exists.
svn path=/trunk/netsurf/; revision=12969
Diffstat (limited to 'utils/nsurl.c')
-rw-r--r-- | utils/nsurl.c | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/utils/nsurl.c b/utils/nsurl.c index 9faf311d7..20dc10632 100644 --- a/utils/nsurl.c +++ b/utils/nsurl.c @@ -192,6 +192,7 @@ static void nsurl__get_string_markers(const char const *url_s, { const char *pos = url_s; /** current position in url_s */ bool is_http = false; + bool trailing_whitespace = false; /* Initialise marker set */ struct url_markers marker = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; @@ -363,18 +364,31 @@ static void nsurl__get_string_markers(const char const *url_s, /* We got to the end of url_s. * Need to skip back over trailing whitespace to find end of URL */ pos--; - while (isspace(*pos)) - pos--; + if (isspace(*pos)) { + trailing_whitespace = true; + while (isspace(*pos)) + pos--; + } + marker.end = pos + 1 - url_s; - /* Ensure last url section doesn't pass end */ - if (marker.fragment > marker.end) marker.fragment = marker.end; - if (marker.query > marker.end) marker.query = marker.end; - if (marker.path > marker.end) marker.path = marker.end; - if (marker.colon_last > marker.end) marker.colon_last = marker.end; - if (marker.at > marker.end) marker.at = marker.end; - if (marker.colon_last > marker.end) marker.colon_last = marker.end; - if (marker.fragment > marker.end) marker.fragment = marker.end; + if (trailing_whitespace == true) { + /* Ensure last url section doesn't pass end */ + if (marker.fragment > marker.end) + marker.fragment = marker.end; + if (marker.query > marker.end) + marker.query = marker.end; + if (marker.path > marker.end) + marker.path = marker.end; + if (marker.colon_last > marker.end) + marker.colon_last = marker.end; + if (marker.at > marker.end) + marker.at = marker.end; + if (marker.colon_last > marker.end) + marker.colon_last = marker.end; + if (marker.fragment > marker.end) + marker.fragment = marker.end; + } /* Got all the URL components pegged out now */ *markers = marker; |