commit 0bf8b20: [Minor] Add helper to decode entities in an std::string

Vsevolod Stakhov vsevolod at highsecure.ru
Fri Jul 9 13:28:04 UTC 2021


Author: Vsevolod Stakhov
Date: 2021-07-09 14:26:44 +0100
URL: https://github.com/rspamd/rspamd/commit/0bf8b20eea56bd939bc40f4c922c3eefbc52749c

[Minor] Add helper to decode entities in an std::string

---
 src/libserver/html/html_entities.cxx | 7 +++++++
 src/libserver/html/html_entities.hxx | 4 +++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/libserver/html/html_entities.cxx b/src/libserver/html/html_entities.cxx
index 84e05953d..fa19463a0 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 d59674906..68084bf92 100644
--- a/src/libserver/html/html_entities.hxx
+++ b/src/libserver/html/html_entities.hxx
@@ -19,10 +19,12 @@
 #pragma once
 
 #include <utility>
+#include <string>
 
 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;
 
 }
 


More information about the Commits mailing list