linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #03283
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2423: Fix url parsing
------------------------------------------------------------
revno: 2423
committer: eMTee <emtee11@xxxxxxxxx>
branch nick: dcplusplus
timestamp: Sat 2011-02-12 21:30:05 +0100
message:
Fix url parsing
modified:
dcpp/Util.cpp
win32/WinUtil.cpp
--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk
Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'dcpp/Util.cpp'
--- dcpp/Util.cpp 2011-01-29 14:15:43 +0000
+++ dcpp/Util.cpp 2011-02-12 20:30:05 +0000
@@ -460,7 +460,7 @@
fileStart = authorityEnd;
}
- protocol = url.substr(protoStart, protoEnd - protoStart);
+ protocol = (protoEnd == string::npos ? Util::emptyString : url.substr(protoStart, protoEnd - protoStart));
if(authorityEnd > authorityStart) {
dcdebug("x");
@@ -499,7 +499,7 @@
port = 80;
} else if(protocol == "https") {
port = 443;
- } else if(protocol == "dchub") {
+ } else if(protocol == "dchub" || protocol.empty()) {
port = 411;
}
} else {
=== modified file 'win32/WinUtil.cpp'
--- win32/WinUtil.cpp 2011-02-01 21:05:24 +0000
+++ win32/WinUtil.cpp 2011-02-12 20:30:05 +0000
@@ -1163,35 +1163,30 @@
bool WinUtil::parseDBLClick(const tstring& str) {
auto url = Text::fromT(str);
string proto, host, file, query, fragment;
- uint16_t port = 411;
+ uint16_t port;
Util::decodeUrl(url, proto, host, port, file, query, fragment);
if(Util::stricmp(proto.c_str(), "adc") == 0 ||
Util::stricmp(proto.c_str(), "adcs") == 0 ||
- Util::stricmp(proto.c_str(), "dchub") == 0 ||
- proto.empty())
+ Util::stricmp(proto.c_str(), "dchub") == 0 )
{
- if(host == "magnet") {
- parseMagnetUri(str);
- } else {
- if(!host.empty()) {
- HubFrame::openWindow(mainWindow->getTabView(), url);
+ if(!host.empty()) {
+ HubFrame::openWindow(mainWindow->getTabView(), url);
+ }
+
+ if(!file.empty()) {
+ if(file[0] == '/') {
+ // Remove any '/' in from of the file
+ file = file.substr(1);
+ if(file.empty()) return true;
}
-
- if(!file.empty()) {
- if(file[0] == '/') {
- // Remove any '/' in from of the file
- file = file.substr(1);
- if(file.empty()) return true;
- }
- try {
- UserPtr user = ClientManager::getInstance()->findLegacyUser(file);
- if(user)
- QueueManager::getInstance()->addList(HintedUser(user, url), QueueItem::FLAG_CLIENT_VIEW);
- // @todo else report error
- } catch (const Exception&) {
- // ...
- }
+ try {
+ UserPtr user = ClientManager::getInstance()->findLegacyUser(file);
+ if(user)
+ QueueManager::getInstance()->addList(HintedUser(user, url), QueueItem::FLAG_CLIENT_VIEW);
+ // @todo else report error
+ } catch (const Exception&) {
+ // ...
}
}
@@ -1201,6 +1196,9 @@
Util::strnicmp(str.c_str(), _T("mailto:"), 7) == 0) {
openLink(str);
return true;
+ } else if(host == "magnet") {
+ parseMagnetUri(str);
+ return true;
}
return false;