aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver/css/css_tokeniser.hxx
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2021-01-26 14:44:01 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2021-01-26 14:44:01 +0000
commit52cb3f8d019522aee0c049d091772d082a8502f1 (patch)
tree17f8406b79b54181382c9ce756fe7d4c8ca42637 /src/libserver/css/css_tokeniser.hxx
parentfcfaab40b8ea772ce9d72773930c329a6277da6d (diff)
downloadrspamd-52cb3f8d019522aee0c049d091772d082a8502f1.tar.gz
rspamd-52cb3f8d019522aee0c049d091772d082a8502f1.zip
[Project] Css: Implement numbers and ident parsers
Diffstat (limited to 'src/libserver/css/css_tokeniser.hxx')
-rw-r--r--src/libserver/css/css_tokeniser.hxx27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/libserver/css/css_tokeniser.hxx b/src/libserver/css/css_tokeniser.hxx
index cff5877c2..5880241c1 100644
--- a/src/libserver/css/css_tokeniser.hxx
+++ b/src/libserver/css/css_tokeniser.hxx
@@ -47,14 +47,36 @@ struct css_parser_token {
ebrace_token, /* ) */
osqbrace_token, /* [ */
esqbrace_token, /* ] */
+ ocurlbrace_token, /* { */
+ ecurlbrace_token, /* } */
comma_token,
colon_token,
semicolon_token,
eof_token,
};
+ enum class dim_type : std::uint8_t {
+ dim_px,
+ dim_em,
+ dim_rem,
+ dim_ex,
+ dim_wv,
+ dim_wh,
+ dim_vmax,
+ dim_vmin,
+ dim_pt,
+ dim_cm,
+ dim_mm,
+ dim_in,
+ dim_pc,
+ };
+
static const std::uint8_t default_flags = 0;
static const std::uint8_t flag_bad_string = (1u << 0u);
+ static const std::uint8_t number_dimension = (1u << 1u);
+ static const std::uint8_t number_percent = (1u << 2u);
+ static const std::uint8_t flag_bad_dimension = (1u << 3u);
+
using value_type = std::variant<std::string_view, /* For strings and string like tokens */
char, /* For delimiters (might need to move to unicode point) */
double, /* For numeric stuff */
@@ -65,10 +87,12 @@ struct css_parser_token {
value_type value;
token_type type;
std::uint8_t flags = default_flags;
+ dim_type dim_type;
css_parser_token() = delete;
explicit css_parser_token(token_type type, const value_type &value) :
value(value), type(type) {}
+ auto adjust_dim(const css_parser_token &dim_token) -> bool;
};
/* Ensure that parser tokens are simple enough */
@@ -86,6 +110,9 @@ private:
std::string_view input;
std::size_t offset;
rspamd_mempool_t *pool;
+
+ auto consume_number() -> struct css_parser_token;
+ auto consume_ident() -> struct css_parser_token;
};
}