diff --git a/Source/Core/Common/StringUtil.cpp b/Source/Core/Common/StringUtil.cpp index c041164f22..3083cc01f0 100644 --- a/Source/Core/Common/StringUtil.cpp +++ b/Source/Core/Common/StringUtil.cpp @@ -675,6 +675,8 @@ std::vector CommandLineToUtf8Argv(const wchar_t* command_line) } #endif +namespace Common +{ std::string GetEscapedHtml(std::string html) { static constexpr std::array, 5> replacements{{ @@ -693,8 +695,6 @@ std::string GetEscapedHtml(std::string html) return html; } -namespace Common -{ void ToLower(std::string* str) { std::transform(str->begin(), str->end(), str->begin(), [](char c) { return Common::ToLower(c); }); diff --git a/Source/Core/Common/StringUtil.h b/Source/Core/Common/StringUtil.h index 9e321ca59a..84462b6c62 100644 --- a/Source/Core/Common/StringUtil.h +++ b/Source/Core/Common/StringUtil.h @@ -234,8 +234,6 @@ std::string ThousandSeparate(I value, int spaces = 0) std::vector CommandLineToUtf8Argv(const wchar_t* command_line); #endif -std::string GetEscapedHtml(std::string html); - namespace Common { /// Returns whether a character is printable, i.e. whether 0x20 <= c <= 0x7e is true. @@ -264,6 +262,8 @@ inline char ToUpper(char ch) return std::toupper(ch, std::locale::classic()); } +std::string GetEscapedHtml(std::string html); + void ToLower(std::string* str); void ToUpper(std::string* str); bool CaseInsensitiveEquals(std::string_view a, std::string_view b); diff --git a/Source/Core/UICommon/AutoUpdate.cpp b/Source/Core/UICommon/AutoUpdate.cpp index e8de74c794..0bf87e4886 100644 --- a/Source/Core/UICommon/AutoUpdate.cpp +++ b/Source/Core/UICommon/AutoUpdate.cpp @@ -118,7 +118,7 @@ std::string GenerateChangelog(const picojson::array& versions) changelog += ver_obj["shortrev"].get(); } const std::string escaped_description = - GetEscapedHtml(ver_obj["short_descr"].get()); + Common::GetEscapedHtml(ver_obj["short_descr"].get()); changelog += " by () + "\">" + ver_obj["author"].get() + " — " + escaped_description; } diff --git a/Source/UnitTests/Common/StringUtilTest.cpp b/Source/UnitTests/Common/StringUtilTest.cpp index 1f1159d1eb..357f7f9500 100644 --- a/Source/UnitTests/Common/StringUtilTest.cpp +++ b/Source/UnitTests/Common/StringUtilTest.cpp @@ -86,7 +86,7 @@ TEST(StringUtil, GetEscapedHtml) static constexpr auto no_escape_needed = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" "!@#$%^*()-_=+,./?;:[]{}| \\\t\n"; - EXPECT_EQ(GetEscapedHtml(no_escape_needed), no_escape_needed); - EXPECT_EQ(GetEscapedHtml("&<>'\""), "&<>'""); - EXPECT_EQ(GetEscapedHtml("&&&"), "&&&"); + EXPECT_EQ(Common::GetEscapedHtml(no_escape_needed), no_escape_needed); + EXPECT_EQ(Common::GetEscapedHtml("&<>'\""), "&<>'""); + EXPECT_EQ(Common::GetEscapedHtml("&&&"), "&&&"); }