back-port file name sanitization patch to RC_1_1
This commit is contained in:
parent
c8d51689bb
commit
3255375095
|
@ -187,9 +187,9 @@ namespace libtorrent
|
||||||
if (element_len == 1 && element[0] == '.') return;
|
if (element_len == 1 && element[0] == '.') return;
|
||||||
|
|
||||||
#ifdef TORRENT_WINDOWS
|
#ifdef TORRENT_WINDOWS
|
||||||
#define TORRENT_SEPARATOR "\\"
|
#define TORRENT_SEPARATOR '\\'
|
||||||
#else
|
#else
|
||||||
#define TORRENT_SEPARATOR "/"
|
#define TORRENT_SEPARATOR '/'
|
||||||
#endif
|
#endif
|
||||||
path.reserve(path.size() + element_len + 2);
|
path.reserve(path.size() + element_len + 2);
|
||||||
int added_separator = 0;
|
int added_separator = 0;
|
||||||
|
@ -417,6 +417,11 @@ namespace libtorrent
|
||||||
|
|
||||||
filename = p.string_ptr() + info_ptr_diff;
|
filename = p.string_ptr() + info_ptr_diff;
|
||||||
filename_len = p.string_length();
|
filename_len = p.string_length();
|
||||||
|
while (filename_len > 0 && filename[0] == TORRENT_SEPARATOR)
|
||||||
|
{
|
||||||
|
filename += 1;
|
||||||
|
filename_len -= 1;
|
||||||
|
}
|
||||||
sanitize_append_path_element(path, p.string_ptr(), p.string_length());
|
sanitize_append_path_element(path, p.string_ptr(), p.string_length());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -438,6 +443,11 @@ namespace libtorrent
|
||||||
filename = e.string_ptr() + info_ptr_diff;
|
filename = e.string_ptr() + info_ptr_diff;
|
||||||
filename_len = e.string_length();
|
filename_len = e.string_length();
|
||||||
}
|
}
|
||||||
|
while (filename_len > 0 && filename[0] == TORRENT_SEPARATOR)
|
||||||
|
{
|
||||||
|
filename += 1;
|
||||||
|
filename_len -= 1;
|
||||||
|
}
|
||||||
sanitize_append_path_element(path, e.string_ptr(), e.string_length());
|
sanitize_append_path_element(path, e.string_ptr(), e.string_length());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -659,7 +669,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
p = parent_path(p);
|
p = parent_path(p);
|
||||||
// we don't want trailing slashes here
|
// we don't want trailing slashes here
|
||||||
TORRENT_ASSERT(p[p.size() - 1] == *TORRENT_SEPARATOR);
|
TORRENT_ASSERT(p[p.size() - 1] == TORRENT_SEPARATOR);
|
||||||
p.resize(p.size() - 1);
|
p.resize(p.size() - 1);
|
||||||
files.insert(p);
|
files.insert(p);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue