@@ -606,7 +606,7 @@ css_parser::consume_input(const std::string_view &sv) | |||
const auto &rules = consumed_blocks->get_blocks_or_empty(); | |||
if (rules.empty()) { | |||
if (error.type == css_parse_error_type::PARSE_ERROR_UNKNOWN_ERROR) { | |||
if (error.type == css_parse_error_type::PARSE_ERROR_NO_ERROR) { | |||
return css_parse_error(css_parse_error_type::PARSE_ERROR_EMPTY, | |||
"no css rules consumed"); | |||
} |
@@ -31,10 +31,11 @@ enum class css_parse_error_type { | |||
PARSE_ERROR_UNKNOWN_OPTION, | |||
PARSE_ERROR_INVALID_SYNTAX, | |||
PARSE_ERROR_BAD_NESTING, | |||
PARSE_ERROR_EMPTY, | |||
PARSE_ERROR_NYI, | |||
PARSE_ERROR_UNKNOWN_ERROR, | |||
/* All above is treated as fatal error in parsing */ | |||
PARSE_ERROR_NO_ERROR, | |||
PARSE_ERROR_EMPTY, | |||
}; | |||
struct css_parse_error { | |||
@@ -45,6 +46,10 @@ struct css_parse_error { | |||
type(type), description(description) {} | |||
explicit css_parse_error (css_parse_error_type type = css_parse_error_type::PARSE_ERROR_NO_ERROR) : | |||
type(type) {} | |||
constexpr auto is_fatal(void) const -> bool { | |||
return type < css_parse_error_type::PARSE_ERROR_NO_ERROR; | |||
} | |||
}; | |||
} |
@@ -1791,11 +1791,14 @@ html_process_input(rspamd_mempool_t *pool, | |||
std::move(hc->css_style)); | |||
if (!ret_maybe.has_value()) { | |||
auto err_str = fmt::format("cannot parse css (error code: {}): {}", | |||
static_cast<int>(ret_maybe.error().type), | |||
ret_maybe.error().description.value_or("unknown error")); | |||
msg_info_pool ("cannot parse css: %*s", | |||
(int) err_str.size(), err_str.data()); | |||
if (ret_maybe.error().is_fatal()) { | |||
auto err_str = fmt::format( | |||
"cannot parse css (error code: {}): {}", | |||
static_cast<int>(ret_maybe.error().type), | |||
ret_maybe.error().description.value_or("unknown error")); | |||
msg_info_pool ("cannot parse css: %*s", | |||
(int) err_str.size(), err_str.data()); | |||
} | |||
} | |||
else { | |||
hc->css_style = ret_maybe.value(); |