diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-07-27 16:25:27 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-07-27 16:25:27 +0100 |
commit | e55eae188b1dc7f1b31c50414e6e0dc202ca425d (patch) | |
tree | 4950162f8af25330dbcfba2ac47d00615223ab2e | |
parent | c8e5dc55f618e34a8f18685942062688968fa390 (diff) | |
download | rspamd-e55eae188b1dc7f1b31c50414e6e0dc202ca425d.tar.gz rspamd-e55eae188b1dc7f1b31c50414e6e0dc202ca425d.zip |
[Minor] Improve error reporting
-rw-r--r-- | src/libserver/css/css_parser.cxx | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/libserver/css/css_parser.cxx b/src/libserver/css/css_parser.cxx index 36550908a..ef3d6f666 100644 --- a/src/libserver/css/css_parser.cxx +++ b/src/libserver/css/css_parser.cxx @@ -149,6 +149,7 @@ public: css_parser(void) = delete; /* Require mempool to be set for logging */ explicit css_parser(rspamd_mempool_t *pool) : pool (pool) { style_object.reset(); + error.type = css_parse_error_type::PARSE_ERROR_NO_ERROR; } /* @@ -156,7 +157,9 @@ public: * destruct it on errors (we assume that it is owned somewhere else) */ explicit css_parser(std::shared_ptr<css_style_sheet> &&existing, rspamd_mempool_t *pool) : - style_object(existing), pool(pool) {} + style_object(existing), pool(pool) { + error.type = css_parse_error_type::PARSE_ERROR_NO_ERROR; + } /* * Process input css blocks @@ -241,7 +244,8 @@ auto css_parser::function_consumer(std::unique_ptr<css_consumed_block> &top) -> if (++rec_level > max_rec) { msg_err_css("max nesting reached, ignore style"); - error = css_parse_error(css_parse_error_type::PARSE_ERROR_BAD_NESTING); + error = css_parse_error(css_parse_error_type::PARSE_ERROR_BAD_NESTING, + "maximum nesting has reached when parsing function value"); return false; } @@ -289,7 +293,8 @@ auto css_parser::simple_block_consumer(std::unique_ptr<css_consumed_block> &top, if (!consume_current && ++rec_level > max_rec) { msg_err_css("max nesting reached, ignore style"); - error = css_parse_error(css_parse_error_type::PARSE_ERROR_BAD_NESTING); + error = css_parse_error(css_parse_error_type::PARSE_ERROR_BAD_NESTING, + "maximum nesting has reached when parsing simple block value"); return false; } @@ -340,7 +345,8 @@ auto css_parser::qualified_rule_consumer(std::unique_ptr<css_consumed_block> &to if (++rec_level > max_rec) { msg_err_css("max nesting reached, ignore style"); - error = css_parse_error(css_parse_error_type::PARSE_ERROR_BAD_NESTING); + error = css_parse_error(css_parse_error_type::PARSE_ERROR_BAD_NESTING, + "maximum nesting has reached when parsing qualified rule value"); return false; } @@ -399,7 +405,8 @@ auto css_parser::at_rule_consumer(std::unique_ptr<css_consumed_block> &top) -> b if (++rec_level > max_rec) { msg_err_css("max nesting reached, ignore style"); - error = css_parse_error(css_parse_error_type::PARSE_ERROR_BAD_NESTING); + error = css_parse_error(css_parse_error_type::PARSE_ERROR_BAD_NESTING, + "maximum nesting has reached when parsing at keyword"); return false; } @@ -463,7 +470,8 @@ auto css_parser::component_value_consumer(std::unique_ptr<css_consumed_block> &t top->token_type_str(), rec_level); if (++rec_level > max_rec) { - error = css_parse_error(css_parse_error_type::PARSE_ERROR_BAD_NESTING); + error = css_parse_error(css_parse_error_type::PARSE_ERROR_BAD_NESTING, + "maximum nesting has reached when parsing component value"); return false; } |