Commit 7ddd0b12 authored by Joris Guisson's avatar Joris Guisson
Browse files

- Remove newlines from path names of files when present in torrent file

- Ensure that the name of a torrent doesn't end with a /, this causes stuff to go wrong when creating directories

BUG: 192652

svn path=/branches/stable/extragear-kde4/network/ktorrent/; revision=968988
parent b2bd73d8
......@@ -13,6 +13,7 @@ Changes in 3.2.2 :
- Config dialog now embeds pages in scroll areas, so that the dialog also is useable on small screens
- Make sure dbus names are valid, this fixes an assert (192007)
- Fix crash when parsing DHT packets (190107)
- Remove newlines from path names of files when present in torrent file (192652)
Changes in 3.2.1 :
- Resort torrents if display name is changed
......
......@@ -37,6 +37,24 @@
namespace bt
{
static QString SanityzeName(const QString & name)
{
#ifdef Q_WS_WIN
QString ret = name;
char invalid[] = {'<','>',':','"','/','\\','|','?','*'};
for (int i = 0;i < 9;i++)
{
if (ret.contains(invalid[i]))
ret = ret.replace(invalid[i],'_');
}
return ret;
#else
if (name.endsWith("/"))
return name.left(name.length() - 1);
return name;
#endif
}
Torrent::Torrent() : piece_length(0),file_length(0),priv_torrent(false),pos_cache_chunk(0),pos_cache_file(0),tmon(0)
{
......@@ -178,6 +196,8 @@ namespace bt
unencoded_path.append(v->data().toByteArray());
QString sd = v->data().toString(text_codec);
if (sd.contains("\n"))
sd = sd.remove("\n");
path += sd;
if (j + 1 < ln->getNumChildren())
path += bt::DirSeparator();
......@@ -291,9 +311,7 @@ namespace bt
unencoded_name = node->data().toByteArray();
name_suggestion = text_codec->toUnicode(unencoded_name);
#ifdef Q_WS_WIN
name_suggestion = NameForWindows(name_suggestion);
#endif
name_suggestion = SanityzeName(name_suggestion);
}
void Torrent::loadAnnounceList(BNode* node)
......@@ -560,9 +578,7 @@ namespace bt
f.changeTextCodec(codec);
}
name_suggestion = text_codec->toUnicode(unencoded_name);
#ifdef Q_WS_WIN
name_suggestion = NameForWindows(name_suggestion);
#endif
name_suggestion = SanityzeName(name_suggestion);
}
void Torrent::downloadPriorityChanged(TorrentFile* tf,Priority newpriority,Priority oldpriority)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment