commit dd13989: [Minor] Add spaces trimming
Vsevolod Stakhov
vsevolod at highsecure.ru
Tue Jun 22 23:28:05 UTC 2021
Author: Vsevolod Stakhov
Date: 2021-06-23 00:26:56 +0100
URL: https://github.com/rspamd/rspamd/commit/dd139891f6bd9f49c0489880ef78e59d8d109521 (HEAD -> master)
[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;
}
More information about the Commits
mailing list