From: Vsevolod Stakhov Date: Fri, 9 Jul 2021 13:26:44 +0000 (+0100) Subject: [Minor] Add helper to decode entities in an std::string X-Git-Tag: 3.0~188 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0bf8b20eea56bd939bc40f4c922c3eefbc52749c;p=thirdparty%2Frspamd.git [Minor] Add helper to decode entities in an std::string --- diff --git a/src/libserver/html/html_entities.cxx b/src/libserver/html/html_entities.cxx index 84e05953d2..fa19463a0b 100644 --- a/src/libserver/html/html_entities.cxx +++ b/src/libserver/html/html_entities.cxx @@ -2572,6 +2572,13 @@ decode_html_entitles_inplace(char *s, std::size_t len, bool norm_spaces) return (t - s); } +auto +decode_html_entitles_inplace(std::string &st) -> void +{ + auto nlen = decode_html_entitles_inplace(st.data(), st.size()); + st.resize(nlen); +} + TEST_SUITE("html") { TEST_CASE("html entities") { diff --git a/src/libserver/html/html_entities.hxx b/src/libserver/html/html_entities.hxx index d596749069..68084bf92f 100644 --- a/src/libserver/html/html_entities.hxx +++ b/src/libserver/html/html_entities.hxx @@ -19,10 +19,12 @@ #pragma once #include +#include namespace rspamd::html { -std::size_t decode_html_entitles_inplace (char *s, std::size_t len, bool norm_spaces = false); +auto decode_html_entitles_inplace(char *s, std::size_t len, bool norm_spaces = false) -> std::size_t ; +auto decode_html_entitles_inplace(std::string &st) -> void; }