commit 310cada: [Minor] Implement C++ function to get tag id by name

Vsevolod Stakhov vsevolod at highsecure.ru
Wed Jun 16 14:28:05 UTC 2021


Author: Vsevolod Stakhov
Date: 2021-06-16 14:48:47 +0100
URL: https://github.com/rspamd/rspamd/commit/310cada28d15cc629e7c4c73fe5a842e2af851ae

[Minor] Implement C++ function to get tag id by name

---
 src/libserver/html/html.cxx | 12 ++++++++++++
 src/libserver/html/html.hxx |  2 ++
 2 files changed, 14 insertions(+)

diff --git a/src/libserver/html/html.cxx b/src/libserver/html/html.cxx
index 139c59bd2..5c5157740 100644
--- a/src/libserver/html/html.cxx
+++ b/src/libserver/html/html.cxx
@@ -1726,6 +1726,18 @@ html_debug_structure(const html_content &hc) -> std::string
 	return output;
 }
 
+auto html_tag_by_name(const std::string_view &name)
+	-> std::optional<tag_id_t>
+{
+	const auto *td = rspamd::html::html_tags_defs.by_name(name);
+
+	if (td != nullptr) {
+		return td->id;
+	}
+
+	return std::nullopt;
+}
+
 /*
  * Tests part
  */
diff --git a/src/libserver/html/html.hxx b/src/libserver/html/html.hxx
index d4a2fb58b..368155d81 100644
--- a/src/libserver/html/html.hxx
+++ b/src/libserver/html/html.hxx
@@ -125,6 +125,8 @@ private:
 };
 
 
+auto html_tag_by_name(const std::string_view &name) -> std::optional<tag_id_t>;
+
 }
 
 #endif //RSPAMD_HTML_HXX


More information about the Commits mailing list