commit f35be29: [Project] Another whitespace hack

Vsevolod Stakhov vsevolod at highsecure.ru
Mon Jul 5 16:42:07 UTC 2021


Author: Vsevolod Stakhov
Date: 2021-07-05 17:41:16 +0100
URL: https://github.com/rspamd/rspamd/commit/f35be29ff27442aeb78828150eda24cc2795bd1d (HEAD -> master)

[Project] Another whitespace hack

---
 src/libserver/html/html.cxx | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/libserver/html/html.cxx b/src/libserver/html/html.cxx
index b29a7d37d..f9aacaf0c 100644
--- a/src/libserver/html/html.cxx
+++ b/src/libserver/html/html.cxx
@@ -1011,8 +1011,18 @@ html_append_content(struct html_content *hc, std::string_view data) -> auto
 {
 	auto cur_offset = hc->parsed.size();
 	hc->parsed.append(data);
+
+	if (cur_offset > 0 && data.size() > 0) {
+		auto last = hc->parsed.back();
+		auto first_appended = data.front();
+		if (first_appended == ' ' && !g_ascii_isspace(last)) {
+			cur_offset++;
+		}
+	}
+
 	auto nlen = decode_html_entitles_inplace(hc->parsed.data() + cur_offset,
 			hc->parsed.size() - cur_offset, true);
+
 	hc->parsed.resize(nlen + cur_offset);
 
 	return nlen;


More information about the Commits mailing list