]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Project] Css: Implement backlog of css tokens
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 4 Feb 2021 20:30:44 +0000 (20:30 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 4 Feb 2021 20:30:44 +0000 (20:30 +0000)
src/libserver/css/css_tokeniser.cxx
src/libserver/css/css_tokeniser.hxx

index b8f4f5ebcfb6e604773a5f03e7ad6bb3ae5a9018..03e70c32f7c5f86f7a7007a98efe0e52a67bd4f0 100644 (file)
@@ -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 */
 
        /*
index 7ef5f464380a6fe47b635a496b34463435844fa0..afe888a80ff0b457fae1f1aeb957686b617244fd 100644 (file)
@@ -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;