commit 8617105: [Minor] Fix entities with space decoding

Vsevolod Stakhov vsevolod at highsecure.ru
Wed Jul 7 20:49:04 UTC 2021


Author: Vsevolod Stakhov
Date: 2021-07-07 21:46:03 +0100
URL: https://github.com/rspamd/rspamd/commit/8617105c7cb7079ba20fa8aaf106b53abac278c3

[Minor] Fix entities with space decoding

---
 src/libserver/html/html_entities.cxx | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/libserver/html/html_entities.cxx b/src/libserver/html/html_entities.cxx
index 9ed080d4f..84e05953d 100644
--- a/src/libserver/html/html_entities.cxx
+++ b/src/libserver/html/html_entities.cxx
@@ -2474,6 +2474,11 @@ decode_html_entitles_inplace(char *s, std::size_t len, bool norm_spaces)
 			if ((*h == ';' || g_ascii_isspace(*h)) && h > e) {
 				replace_entity();
 				state = parser_state::normal_content;
+
+				if (g_ascii_isspace(*h)) {
+					/* Avoid increase of h */
+					continue;
+				}
 			}
 			else if (*h == '&') {
 				/* Previous `&` was bogus */
@@ -2580,7 +2585,7 @@ TEST_SUITE("html") {
 				{"    abc def   ", "abc def "},
 				{"FOO>BAR", "FOO>BAR"},
 				{"FOO&gtBAR", "FOO>BAR"},
-				{"FOO&gt BAR", "FOO>BAR"},
+				{"FOO&gt BAR", "FOO> BAR"},
 				{"FOO>;;BAR", "FOO>;;BAR"},
 				{"I'm ¬it;", "I'm ¬it;"},
 				{"I'm ∉", "I'm ∉"},


More information about the Commits mailing list