]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Project] Another whitespace hack
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 5 Jul 2021 16:41:16 +0000 (17:41 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 5 Jul 2021 16:41:16 +0000 (17:41 +0100)
src/libserver/html/html.cxx

index b29a7d37dbda79735b2d471d87d6fbcf0f4f1269..f9aacaf0cfa11bae054e00b9624d76f798ee7046 100644 (file)
@@ -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;