The attached patch replaces spaces with %20 in .torrent file URLs.
I've run across a lot of torrent URLs with spaces in them lately, and
it's getting somewhat tiring to do the replacement manually. I'd
appreciate it if this functionality could be integrated into rtorrent.
Index: src/core/download_factory.cc
===================================================================
--- src/core/download_factory.cc (revision 1067)
+++ src/core/download_factory.cc (working copy)
@@ -59,6 +59,19 @@
#include "download_factory.h"
#include "download_store.h"
+namespace {
+
+void find_and_replace(std::string& str, const char find, const std::string& replacement) {
+ std::size_t pos = 0;
+
+ while ((pos = str.find(find, pos)) != std::string::npos) {
+ str.replace(pos, 1, replacement);
+ pos += replacement.size();
+ }
+}
+
+}
+
namespace core {
bool
@@ -125,6 +138,7 @@
if (is_network_uri(m_uri)) {
// Http handling here.
+ find_and_replace(m_uri, ' ', "%20");
m_stream = new std::stringstream;
HttpQueue::iterator itr = m_manager->http_queue()->insert(m_uri, m_stream);
_______________________________________________
Libtorrent-devel mailing list
[email protected]
http://rakshasa.no/mailman/listinfo/libtorrent-devel