rspamd_css rspamd_css_parse_style (rspamd_mempool_t *pool,
const guchar *begin,
gsize len, GError **err);
+
+/*
+ * Unescape css
+ */
+const gchar *rspamd_css_unescape (rspamd_mempool_t *pool,
+ const guchar *begin,
+ gsize len,
+ gsize *outlen);
#ifdef __cplusplus
}
#endif
return tl::make_unexpected (error);
}
+ /* Public for unit tests */
+ std::string_view unescape_css(const std::string_view &sv);
+
private:
enum class parser_state {
initial_state,
/* Helper parser methods */
bool need_unescape(const std::string_view &sv);
-
- std::string_view unescape_css(const std::string_view &sv);
};
/*
}
}
+
+/* C API */
+const gchar *rspamd_css_unescape (rspamd_mempool_t *pool,
+ const guchar *begin,
+ gsize len,
+ gsize *outlen)
+{
+ rspamd::css::css_parser parser(pool);
+ auto sv = parser.unescape_css({(const char*)begin, len});
+ const auto *v = sv.begin();
+
+ if (outlen) {
+ *outlen = sv.size();
+ }
+
+ return v;
+}