diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-02-04 20:30:44 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-02-04 20:30:44 +0000 |
commit | 9d94e62947e88a71c229677d8cb1450a4a601d23 (patch) | |
tree | 3ea2ba7de61c7900bca4901af0a6d0e8facf1ffa /src/libserver | |
parent | 1daf44c4b14f73c8eacb1864c7f905ca795057d1 (diff) | |
download | rspamd-9d94e62947e88a71c229677d8cb1450a4a601d23.tar.gz rspamd-9d94e62947e88a71c229677d8cb1450a4a601d23.zip |
[Project] Css: Implement backlog of css tokens
Diffstat (limited to 'src/libserver')
-rw-r--r-- | src/libserver/css/css_tokeniser.cxx | 8 | ||||
-rw-r--r-- | src/libserver/css/css_tokeniser.hxx | 6 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/libserver/css/css_tokeniser.cxx b/src/libserver/css/css_tokeniser.cxx index b8f4f5ebc..03e70c32f 100644 --- a/src/libserver/css/css_tokeniser.cxx +++ b/src/libserver/css/css_tokeniser.cxx @@ -209,7 +209,6 @@ css_parser_token::adjust_dim(const css_parser_token &dim_token) -> bool } else { flags |= css_parser_token::flag_bad_dimension; - msg_err("hui: %*s", (int)sv.size(), sv.begin()); return false; } @@ -445,6 +444,13 @@ auto css_tokeniser::consume_number() -> struct css_parser_token */ auto css_tokeniser::next_token(void) -> struct css_parser_token { + /* Check pushback queue */ + if (!backlog.empty()) { + auto &tok = backlog.front(); + backlog.pop_front(); + + return std::move(tok); + } /* Helpers */ /* diff --git a/src/libserver/css/css_tokeniser.hxx b/src/libserver/css/css_tokeniser.hxx index 7ef5f4643..afe888a80 100644 --- a/src/libserver/css/css_tokeniser.hxx +++ b/src/libserver/css/css_tokeniser.hxx @@ -22,6 +22,7 @@ #include <string_view> #include <utility> #include <variant> +#include <list> #include "mem_pool.h" namespace rspamd::css { @@ -91,6 +92,7 @@ struct css_parser_token { explicit css_parser_token(token_type type, const value_type &value) : value(value), type(type) {} css_parser_token(css_parser_token &&other) = default; + auto operator=(css_parser_token &&other) -> css_parser_token& = default; auto adjust_dim(const css_parser_token &dim_token) -> bool; /* Debugging routines */ @@ -110,10 +112,14 @@ public: auto next_token(void) -> struct css_parser_token; auto get_offset(void) const { return offset; } + auto pushback_token(struct css_parser_token &&t) const -> void { + backlog.push_back(std::forward<css_parser_token>(t)); + } private: std::string_view input; std::size_t offset; rspamd_mempool_t *pool; + mutable std::list<css_parser_token> backlog; auto consume_number() -> struct css_parser_token; auto consume_ident() -> struct css_parser_token; |