1
0
Fork 0
mirror of https://github.com/KingDuckZ/kamokan.git synced 2025-08-03 12:50:02 +00:00

Add unit test for utf8 sanitization.

This commit is contained in:
King_DuckZ 2017-05-10 20:47:24 +01:00
parent 13e46ab1e6
commit d449781c40
7 changed files with 2125 additions and 1 deletions

View file

@ -53,6 +53,24 @@ namespace tawashi {
return std::string(buf->ptr, buf->size);
}
std::string Escapist::escape_url (const boost::string_ref& parURL) const {
if (parURL.empty())
return std::string();
assert(m_gh_buf);
gh_buf* const buf = static_cast<gh_buf*>(m_gh_buf);
const int escaped = houdini_escape_url(
buf,
reinterpret_cast<const uint8_t*>(parURL.data()),
parURL.size()
);
if (0 == escaped)
return std::string(parURL.data(), parURL.size());
else
return std::string(buf->ptr, buf->size);
}
std::string Escapist::escape_html (const boost::string_ref& parHtml) const {
if (parHtml.empty())
return std::string();

View file

@ -37,6 +37,7 @@ namespace tawashi {
~Escapist() noexcept;
std::string unescape_url (const boost::string_ref& parURL) const;
std::string escape_url (const boost::string_ref& parURL) const;
std::string escape_html (const boost::string_ref& parHtml) const;
private: