mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-21 19:47:32 +01:00
StringUtil: Move GetEscapedHtml() into Common namespace
This commit is contained in:
parent
21df3ca572
commit
d368c989e7
@ -675,6 +675,8 @@ std::vector<std::string> CommandLineToUtf8Argv(const wchar_t* command_line)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
namespace Common
|
||||||
|
{
|
||||||
std::string GetEscapedHtml(std::string html)
|
std::string GetEscapedHtml(std::string html)
|
||||||
{
|
{
|
||||||
static constexpr std::array<std::array<const char*, 2>, 5> replacements{{
|
static constexpr std::array<std::array<const char*, 2>, 5> replacements{{
|
||||||
@ -693,8 +695,6 @@ std::string GetEscapedHtml(std::string html)
|
|||||||
return html;
|
return html;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Common
|
|
||||||
{
|
|
||||||
void ToLower(std::string* str)
|
void ToLower(std::string* str)
|
||||||
{
|
{
|
||||||
std::transform(str->begin(), str->end(), str->begin(), [](char c) { return Common::ToLower(c); });
|
std::transform(str->begin(), str->end(), str->begin(), [](char c) { return Common::ToLower(c); });
|
||||||
|
@ -234,8 +234,6 @@ std::string ThousandSeparate(I value, int spaces = 0)
|
|||||||
std::vector<std::string> CommandLineToUtf8Argv(const wchar_t* command_line);
|
std::vector<std::string> CommandLineToUtf8Argv(const wchar_t* command_line);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::string GetEscapedHtml(std::string html);
|
|
||||||
|
|
||||||
namespace Common
|
namespace Common
|
||||||
{
|
{
|
||||||
/// Returns whether a character is printable, i.e. whether 0x20 <= c <= 0x7e is true.
|
/// 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());
|
return std::toupper(ch, std::locale::classic());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string GetEscapedHtml(std::string html);
|
||||||
|
|
||||||
void ToLower(std::string* str);
|
void ToLower(std::string* str);
|
||||||
void ToUpper(std::string* str);
|
void ToUpper(std::string* str);
|
||||||
bool CaseInsensitiveEquals(std::string_view a, std::string_view b);
|
bool CaseInsensitiveEquals(std::string_view a, std::string_view b);
|
||||||
|
@ -118,7 +118,7 @@ std::string GenerateChangelog(const picojson::array& versions)
|
|||||||
changelog += ver_obj["shortrev"].get<std::string>();
|
changelog += ver_obj["shortrev"].get<std::string>();
|
||||||
}
|
}
|
||||||
const std::string escaped_description =
|
const std::string escaped_description =
|
||||||
GetEscapedHtml(ver_obj["short_descr"].get<std::string>());
|
Common::GetEscapedHtml(ver_obj["short_descr"].get<std::string>());
|
||||||
changelog += " by <a href = \"" + ver_obj["author_url"].get<std::string>() + "\">" +
|
changelog += " by <a href = \"" + ver_obj["author_url"].get<std::string>() + "\">" +
|
||||||
ver_obj["author"].get<std::string>() + "</a> — " + escaped_description;
|
ver_obj["author"].get<std::string>() + "</a> — " + escaped_description;
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ TEST(StringUtil, GetEscapedHtml)
|
|||||||
static constexpr auto no_escape_needed =
|
static constexpr auto no_escape_needed =
|
||||||
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
||||||
"!@#$%^*()-_=+,./?;:[]{}| \\\t\n";
|
"!@#$%^*()-_=+,./?;:[]{}| \\\t\n";
|
||||||
EXPECT_EQ(GetEscapedHtml(no_escape_needed), no_escape_needed);
|
EXPECT_EQ(Common::GetEscapedHtml(no_escape_needed), no_escape_needed);
|
||||||
EXPECT_EQ(GetEscapedHtml("&<>'\""), "&<>'"");
|
EXPECT_EQ(Common::GetEscapedHtml("&<>'\""), "&<>'"");
|
||||||
EXPECT_EQ(GetEscapedHtml("&&&"), "&&&");
|
EXPECT_EQ(Common::GetEscapedHtml("&&&"), "&&&");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user