commit 0e84ee1: [Rework] Html: Forgot to add the internal include

Vsevolod Stakhov vsevolod at highsecure.ru
Wed Jun 2 19:56:06 UTC 2021


Author: Vsevolod Stakhov
Date: 2021-06-01 20:18:30 +0100
URL: https://github.com/rspamd/rspamd/commit/0e84ee1e726e12a264c244632b7f9d71059b2a54

[Rework] Html: Forgot to add the internal include

---
 src/libserver/html/html.hxx | 76 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)

diff --git a/src/libserver/html/html.hxx b/src/libserver/html/html.hxx
new file mode 100644
index 000000000..c3f3830ec
--- /dev/null
+++ b/src/libserver/html/html.hxx
@@ -0,0 +1,76 @@
+/*-
+ * Copyright 2021 Vsevolod Stakhov
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef RSPAMD_HTML_HXX
+#define RSPAMD_HTML_HXX
+#pragma once
+
+#include "config.h"
+#include "libserver/url.h"
+#include "libserver/html/html_tag.hxx"
+#include "libserver/html/html.h"
+#include "libserver/html/html_tags.h"
+
+#include <vector>
+#include <memory>
+
+namespace rspamd::html {
+
+struct html_content {
+	struct rspamd_url *base_url = nullptr;
+	GNode *html_tags;
+	gint flags = 0;
+	guint total_tags = 0;
+	struct html_color bgcolor;
+	std::vector<bool> tags_seen;
+	std::vector<html_image *> images;
+	std::vector<html_block *> blocks;
+	std::vector<std::unique_ptr<struct html_tag>> all_tags;
+	std::string parsed;
+	void *css_style;
+
+	/* Preallocate and reserve all internal structures */
+	html_content() {
+		html_tags =  g_node_new(nullptr);
+		tags_seen.resize(N_TAGS, false);
+		blocks.reserve(128);
+		all_tags.reserve(128);
+		parsed.reserve(256);
+		/* Set white background color by default */
+		bgcolor.d.comp.alpha = 0;
+		bgcolor.d.comp.r = 255;
+		bgcolor.d.comp.g = 255;
+		bgcolor.d.comp.b = 255;
+		bgcolor.valid = TRUE;
+	}
+
+	static void html_content_dtor(void *ptr) {
+		delete html_content::from_ptr(ptr);
+	}
+
+	static auto from_ptr(void *ptr) -> html_content * {
+		return static_cast<html_content* >(ptr);
+	}
+
+private:
+	~html_content() {
+		g_node_destroy(html_tags);
+	}
+};
+
+}
+
+#endif //RSPAMD_HTML_HXX


More information about the Commits mailing list