]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Add spaces trimming
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 22 Jun 2021 23:26:56 +0000 (00:26 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 22 Jun 2021 23:27:18 +0000 (00:27 +0100)
src/libserver/html/html.cxx

index c8ec0858b5ef6be3ec811c00e8bd4f422c8b0d6a..683f92006790c602728649dff3f98aa20796b00c 100644 (file)
@@ -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;
 }