From c74c317ab574779524fe2e20136aed03044d6b3a Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sat, 26 Nov 2016 15:39:00 +0100 Subject: IOS HLE: More robust escaping of NAND paths Prevents path traversal without needing an absolute path function, and also improves accuracy (character sequences like ../ appear to have no special meaning in IOS). This removes the creation and usage of /sys/replace, because the new escapes are too complicated to all be representable in its format and because no other NAND handling software seems to use /sys/replace. --- Source/Core/Common/StringUtil.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'Source/Core/Common/StringUtil.cpp') diff --git a/Source/Core/Common/StringUtil.cpp b/Source/Core/Common/StringUtil.cpp index 5048446682..6f3567e782 100644 --- a/Source/Core/Common/StringUtil.cpp +++ b/Source/Core/Common/StringUtil.cpp @@ -10,7 +10,9 @@ #include #include #include +#include #include +#include #include #include @@ -328,6 +330,21 @@ void SplitString(const std::string& str, const char delim, std::vector& strings, const std::string& delimiter) +{ + // Check if we can return early, just for speed + if (strings.empty()) + return ""; + + std::stringstream res; + std::copy(strings.begin(), strings.end(), + std::ostream_iterator(res, delimiter.c_str())); + + // Drop the trailing delimiter. + std::string joined = res.str(); + return joined.substr(0, joined.length() - delimiter.length()); +} + std::string TabsToSpaces(int tab_size, const std::string& in) { const std::string spaces(tab_size, ' '); -- cgit v1.2.3