linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #05851
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2998: trim more chars from urls
------------------------------------------------------------
revno: 2998
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Fri 2012-07-13 20:50:28 +0200
message:
trim more chars from urls
modified:
dcpp/HttpConnection.cpp
dcpp/Util.cpp
dcpp/Util.h
win32/HubFrame.cpp
win32/MainWindow.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/HttpConnection.cpp'
--- dcpp/HttpConnection.cpp 2012-06-21 18:52:47 +0000
+++ dcpp/HttpConnection.cpp 2012-07-13 18:50:28 +0000
@@ -24,8 +24,6 @@
#include "SettingsManager.h"
#include "version.h"
-#include <boost/algorithm/string/trim.hpp>
-
namespace dcpp {
static const std::string CORAL_SUFFIX = ".nyud.net";
@@ -57,8 +55,7 @@
void HttpConnection::downloadFile(const string& aUrl) {
dcassert(Util::findSubString(aUrl, "http://";) == 0);
currentUrl = aUrl;
- // Trim whitespaces
- boost::algorithm::trim(currentUrl);
+ Util::sanitizeUrl(currentUrl);
// reset all settings (as in constructor), moved here from onLine(302) because ok was not reset properly
moved302 = false;
@@ -156,8 +153,7 @@
socket = NULL;
string location302 = aLine.substr(10, aLine.length() - 10);
- // shave off any sort of line endings - some servers reportedly even omit it
- boost::algorithm::trim(location302);
+ Util::sanitizeUrl(location302);
// make sure we can also handle redirects with relative paths
if(Util::strnicmp(location302.c_str(), "http://";, 7) != 0) {
=== modified file 'dcpp/Util.cpp'
--- dcpp/Util.cpp 2012-07-11 17:13:42 +0000
+++ dcpp/Util.cpp 2012-07-13 18:50:28 +0000
@@ -22,10 +22,12 @@
#ifdef _WIN32
#include "w.h"
-#include "shlobj.h"
+#include <shlobj.h>
#endif
+#include <boost/algorithm/string/trim.hpp>
+
#include "CID.h"
#include "ClientManager.h"
#include "ConnectivityManager.h"
@@ -371,6 +373,10 @@
return Text::toUtf8(buf);
}
+void Util::sanitizeUrl(string& url) {
+ boost::algorithm::trim_if(url, boost::is_space() || boost::is_any_of("<>\""));
+}
+
/**
* Decodes a URL the best it can...
* Default ports:
=== modified file 'dcpp/Util.h'
--- dcpp/Util.h 2012-07-11 17:13:42 +0000
+++ dcpp/Util.h 2012-07-13 18:50:28 +0000
@@ -220,6 +220,7 @@
replace(string_t(search), string_t(replacement), str);
}
+ static void sanitizeUrl(string& url);
static void decodeUrl(const string& aUrl, string& protocol, string& host, string& port, string& path, string& query, string& fragment);
static map<string, string> decodeQuery(const string& query);
=== modified file 'win32/HubFrame.cpp'
--- win32/HubFrame.cpp 2012-07-12 13:17:54 +0000
+++ win32/HubFrame.cpp 2012-07-13 18:50:28 +0000
@@ -20,8 +20,6 @@
#include "HubFrame.h"
-#include <boost/algorithm/string/trim.hpp>
-
#include <dcpp/AdcHub.h>
#include <dcpp/ChatMessage.h>
#include <dcpp/ClientManager.h>
@@ -71,7 +69,7 @@
HubFrame::FrameList HubFrame::frames;
void HubFrame::openWindow(TabViewPtr parent, string url, bool activate, bool connect) {
- boost::algorithm::trim(url);
+ Util::sanitizeUrl(url);
if(url.empty()) {
dwt::MessageBox(WinUtil::mainWindow).show(T_("Empty hub address specified"), _T(APPNAME) _T(" ") _T(VERSIONSTRING),
@@ -1433,7 +1431,7 @@
}
void HubFrame::redirect(string&& target) {
- boost::algorithm::trim(target);
+ Util::sanitizeUrl(target);
if(target.empty()) {
addStatus(T_("Redirect request to an empty hub address"));
=== modified file 'win32/MainWindow.cpp'
--- win32/MainWindow.cpp 2012-07-07 16:36:41 +0000
+++ win32/MainWindow.cpp 2012-07-13 18:50:28 +0000
@@ -1493,7 +1493,7 @@
(i = cmdLine.find(_T("adcs://"))) != string::npos ||
(i = cmdLine.find(_T("magnet:?"))) != string::npos )
{
- WinUtil::parseLink(cmdLine.substr(i));
+ WinUtil::parseLink(cmdLine.substr(i), false);
}
}
=== modified file 'win32/WinUtil.cpp'
--- win32/WinUtil.cpp 2012-07-07 16:36:41 +0000
+++ win32/WinUtil.cpp 2012-07-13 18:50:28 +0000
@@ -1399,6 +1399,8 @@
bool WinUtil::parseLink(const tstring& str, bool followExternal) {
auto url = Text::fromT(str);
+ Util::sanitizeUrl(url);
+
string proto, host, port, file, query, fragment;
Util::decodeUrl(url, proto, host, port, file, query, fragment);