From: Vsevolod Stakhov Date: Tue, 22 Jun 2021 23:26:56 +0000 (+0100) Subject: [Minor] Add spaces trimming X-Git-Tag: 3.0~257 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=dd139891f6bd9f49c0489880ef78e59d8d109521;p=rspamd.git [Minor] Add spaces trimming --- diff --git a/src/libserver/html/html.cxx b/src/libserver/html/html.cxx index c8ec0858b..683f92006 100644 --- a/src/libserver/html/html.cxx +++ b/src/libserver/html/html.cxx @@ -1694,6 +1694,24 @@ html_process_input(rspamd_mempool_t *pool, break; } + if (!hc->parsed.empty()) { + /* Trim extra spaces at the at the end if needed */ + if (g_ascii_isspace(hc->parsed.back())) { + auto last_it = std::end(hc->parsed); + + /* Allow last newline */ + if (hc->parsed.back() == '\n') { + --last_it; + } + + hc->parsed.erase(std::find_if(hc->parsed.rbegin(), hc->parsed.rend(), + [](auto ch) -> auto { + return !g_ascii_isspace(ch); + }).base(), + last_it); + } + } + return hc; }