From dd139891f6bd9f49c0489880ef78e59d8d109521 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 23 Jun 2021 00:26:56 +0100 Subject: [PATCH] [Minor] Add spaces trimming --- src/libserver/html/html.cxx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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; } -- 2.39.5