]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Implement C++ function to get tag id by name
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 16 Jun 2021 13:48:47 +0000 (14:48 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 16 Jun 2021 13:48:47 +0000 (14:48 +0100)
src/libserver/html/html.cxx
src/libserver/html/html.hxx

index 139c59bd2fa51a848ab36ae209fe563eb1f72644..5c5157740c6b6c741eb49410b488c98433cddc43 100644 (file)
@@ -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
  */
index d4a2fb58b2192158d28f120ee8071510f894eac3..368155d81eac69925fba918b24d61dfb3589da0f 100644 (file)
@@ -125,6 +125,8 @@ private:
 };
 
 
+auto html_tag_by_name(const std::string_view &name) -> std::optional<tag_id_t>;
+
 }
 
 #endif //RSPAMD_HTML_HXX