diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/vmime/utility/url.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/vmime/utility/url.cpp b/src/vmime/utility/url.cpp index e8978d28..f0d9c657 100644 --- a/src/vmime/utility/url.cpp +++ b/src/vmime/utility/url.cpp @@ -274,9 +274,20 @@ void url::parse(const string& str) { extractHost(hostPart, host, port); // Path - string path = utility::stringUtils::trim(string(str.begin() + slashPos, str.end())); + string path; string params; + if (slashPos != str.size()) { + + // Cf. RFC 1738 ยง3.1 page 6. For all URLs that follow Common + // Internet Scheme Syntax (and this parser demands it by only + // allowing URLs with "://" above), the separator is not + // actually part of the path. + auto pathStart = slashPos + 1; + path = utility::stringUtils::trim(string(str.begin() + pathStart, str.end())); + + } + size_t paramSep = path.find_first_of('?'); if (paramSep != string::npos) { @@ -285,10 +296,6 @@ void url::parse(const string& str) { path.erase(path.begin() + paramSep, path.end()); } - if (path == "/") { - path.clear(); - } - // Some sanity check if (proto.empty()) { |