diff options
author | Vincent Richard <[email protected]> | 2004-12-26 16:42:30 +0000 |
---|---|---|
committer | Vincent Richard <[email protected]> | 2004-12-26 16:42:30 +0000 |
commit | 057e8a4cfad296f592871cf4ab675ea9fe920826 (patch) | |
tree | 31716abd9c886abcaa26c56edef32bbccbb6722c | |
parent | Oops, forgot a close() when writing to .pc file. (diff) | |
download | vmime-057e8a4cfad296f592871cf4ab675ea9fe920826.tar.gz vmime-057e8a4cfad296f592871cf4ab675ea9fe920826.zip |
Fixed bug in URL parsing.
Diffstat (limited to '')
-rw-r--r-- | src/messaging/url.cpp | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/src/messaging/url.cpp b/src/messaging/url.cpp index f8b24fd7..b770482b 100644 --- a/src/messaging/url.cpp +++ b/src/messaging/url.cpp @@ -143,26 +143,34 @@ void url::parse(const string& str) string username; string password; - if (atPos != string::npos && atPos < slashPos) + if (proto == PROTOCOL_FILE) { - const string userPart(str.begin() + protoEnd, str.begin() + atPos); - const string::size_type colonPos = userPart.find(':'); - - if (colonPos == string::npos) + // No user name, password and host part. + slashPos = protoEnd + 3; + } + else + { + if (atPos != string::npos && atPos < slashPos) { - username = userPart; + const string userPart(str.begin() + protoEnd + 3, str.begin() + atPos); + const string::size_type colonPos = userPart.find(':'); + + if (colonPos == string::npos) + { + username = userPart; + } + else + { + username = string(userPart.begin(), userPart.begin() + colonPos); + password = string(userPart.begin() + colonPos + 1, userPart.end()); + } + + hostPart = string(str.begin() + atPos + 1, str.begin() + slashPos); } else { - username = string(userPart.begin(), userPart.begin() + colonPos); - password = string(userPart.begin() + colonPos + 1, userPart.end()); + hostPart = string(str.begin() + protoEnd + 3, str.begin() + slashPos); } - - hostPart = string(str.begin() + atPos + 1, str.begin() + slashPos); - } - else - { - hostPart = string(str.begin() + protoEnd, str.begin() + slashPos); } // Host/port @@ -182,7 +190,7 @@ void url::parse(const string& str) } // Path - string path(str.begin() + slashPos, str.end()); + string path = stringUtils::trim(string(str.begin() + slashPos, str.end())); if (path == "/") path.clear(); |