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:
parent
13e46ab1e6
commit
d449781c40
7 changed files with 2125 additions and 1 deletions
|
@ -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();
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue