commit 2a6d09b: [Minor] Fix tags offset once conent part is done

Vsevolod Stakhov vsevolod at highsecure.ru
Mon Jul 5 16:56:04 UTC 2021


Author: Vsevolod Stakhov
Date: 2021-07-05 17:54:24 +0100
URL: https://github.com/rspamd/rspamd/commit/2a6d09bd0f05ec668d4d52c1bb6225c4b6a791e1 (HEAD -> master)

[Minor] Fix tags offset once conent part is done

---
 src/libserver/html/html.cxx | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/libserver/html/html.cxx b/src/libserver/html/html.cxx
index f9aacaf0c..4c780686e 100644
--- a/src/libserver/html/html.cxx
+++ b/src/libserver/html/html.cxx
@@ -1061,6 +1061,11 @@ html_append_tag_content(rspamd_mempool_t *pool,
 	goffset next_tag_offset = tag->closing.end,
 			initial_dest_offset = hc->parsed.size();
 
+	auto calculate_final_tag_offsets = [&tag, initial_dest_offset, hc]() -> void {
+		tag->content_offset = initial_dest_offset;
+		tag->closing.start = hc->parsed.size();
+	};
+
 	if (tag->closing.end == -1) {
 		if (tag->closing.start != -1) {
 			next_tag_offset = tag->closing.start;
@@ -1097,10 +1102,16 @@ html_append_tag_content(rspamd_mempool_t *pool,
 			hc->parsed.append("\n");
 		}
 
-		return tag->content_offset;
+		auto ret = tag->content_offset;
+		calculate_final_tag_offsets();
+
+		return ret;
 	}
 	else if (tag->id == Tag_HEAD) {
-		return tag->closing.end;
+		auto ret = tag->closing.end;
+		calculate_final_tag_offsets();
+
+		return ret;
 	}
 
 	if ((tag->flags & (FL_COMMENT|FL_XML|FL_IGNORE|CM_HEAD))) {
@@ -1192,6 +1203,8 @@ html_append_tag_content(rspamd_mempool_t *pool,
 		}
 	}
 
+	calculate_final_tag_offsets();
+
 	return next_tag_offset;
 }
 


More information about the Commits mailing list