From 8fdeeb0497902ac512722b7caa7c2f7deff9f09c Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Fri, 13 Nov 2009 02:50:07 +0000 Subject: [PATCH] don't replace invalid path characters in non-path strings --- src/torrent_info.cpp | 8 ++++---- test/test_primitives.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/torrent_info.cpp b/src/torrent_info.cpp index 74fc337af..37b79d7d3 100644 --- a/src/torrent_info.cpp +++ b/src/torrent_info.cpp @@ -90,7 +90,7 @@ namespace libtorrent // fixes invalid UTF-8 sequences and // replaces characters that are invalid // in paths - bool verify_encoding(std::string& target) + bool verify_encoding(std::string& target, bool fix_paths = false) { std::string tmp_path; bool valid_encoding = true; @@ -101,7 +101,7 @@ namespace libtorrent if ((*i & 0x80) == 0) { // replace invalid characters with '.' - if (valid_path_character(*i)) + if (!fix_paths || valid_path_character(*i)) { tmp_path += *i; } @@ -184,7 +184,7 @@ namespace libtorrent void verify_encoding(file_entry& target) { std::string p = target.path; - if (!verify_encoding(p)) target.path = p; + if (!verify_encoding(p, true)) target.path = p; } // TODO: should this take a char const*? @@ -660,7 +660,7 @@ namespace libtorrent } // correct utf-8 encoding errors - verify_encoding(name); + verify_encoding(name, true); // extract file list lazy_entry const* i = info.dict_find_list("files"); diff --git a/test/test_primitives.cpp b/test/test_primitives.cpp index 9832a8571..a88bc05c3 100644 --- a/test/test_primitives.cpp +++ b/test/test_primitives.cpp @@ -358,7 +358,7 @@ struct parse_state namespace libtorrent { // defined in torrent_info.cpp - bool verify_encoding(std::string& target); + bool verify_encoding(std::string& target, bool path = true); } void find_control_url(int type, char const* string, parse_state& state);