commit dc0d542: [Minor] Limit whitespace trimming
Vsevolod Stakhov
vsevolod at highsecure.ru
Wed Jul 7 12:14:04 UTC 2021
Author: Vsevolod Stakhov
Date: 2021-07-07 13:09:38 +0100
URL: https://github.com/rspamd/rspamd/commit/dc0d54237944801b29d509dd3fcb8ef9940f86fe (HEAD -> master)
[Minor] Limit whitespace trimming
---
src/libserver/html/html.cxx | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/libserver/html/html.cxx b/src/libserver/html/html.cxx
index 480a979e3..e0a57387e 100644
--- a/src/libserver/html/html.cxx
+++ b/src/libserver/html/html.cxx
@@ -1093,12 +1093,14 @@ html_append_tag_content(rspamd_mempool_t *pool,
if (is_visible) {
if (!hc->parsed.empty() && hc->parsed.back() != c && hc->parsed.back() != '\n') {
if (hc->parsed.back() == ' ') {
- /* We also strip extra spaces at the end */
- hc->parsed.erase(std::find_if(hc->parsed.rbegin(), hc->parsed.rend(),
+ /* We also strip extra spaces at the end, but limiting the start */
+ auto last = std::make_reverse_iterator(hc->parsed.begin() + initial_dest_offset);
+ auto first = std::find_if(hc->parsed.rbegin(), last,
[](auto ch) -> auto {
return ch != ' ';
- }).base(),
- hc->parsed.end());
+ });
+ hc->parsed.erase(first.base(), hc->parsed.end());
+ g_assert(hc->parsed.size() >= initial_dest_offset);
}
hc->parsed.push_back(c);
}
More information about the Commits
mailing list