]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Process visibility property
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 9 Jun 2021 13:41:16 +0000 (14:41 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 9 Jun 2021 13:41:16 +0000 (14:41 +0100)
src/libserver/css/css_property.hxx
src/libserver/css/css_rule.cxx
src/libserver/css/css_rule.hxx

index 82ef9808cc120ba07fa23d75d43989bcb99b144c..0e17e39fe43a280256a1061880dc7ceef2d3f815 100644 (file)
@@ -126,6 +126,10 @@ struct alignas(int) css_property {
                return type == css_property_type::PROPERTY_DISPLAY;
        }
 
+       auto is_visibility(void) const -> bool {
+               return type == css_property_type::PROPERTY_VISIBILITY;
+       }
+
        auto operator==(const css_property &other) const { return type == other.type; }
 };
 
index 238998009fdf0a5ffe6ea37b0f2d98953b1f2b74..2e84aaa1c251a75d1d98c524bef0e04642e9e93b 100644 (file)
@@ -180,6 +180,16 @@ allowed_property_value(const css_property &prop, const css_consumed_block &parse
                        }
                }
        }
+       if (prop.is_visibility()) {
+               if (parser_block.is_token()) {
+                       /* A single token */
+                       const auto &tok = parser_block.get_token_or_empty();
+
+                       if (tok.type == css_parser_token::token_type::ident_token) {
+                               return css_value::maybe_display_from_string(tok.get_string_or_default(""));
+                       }
+               }
+       }
        if (prop.is_normal_number()) {
                if (parser_block.is_token()) {
                        /* A single token */
@@ -369,10 +379,12 @@ css_declarations_block::merge_block(const css_declarations_block &other, merge_t
        }
 }
 
-void css_rule::add_value(const css_value &value) {
+void css_rule::add_value(const css_value &value)
+{
        values.push_back(value);
 }
 
+
 TEST_SUITE("css rules") {
        TEST_CASE("simple css rules") {
                const std::vector<std::pair<const char *, std::vector<css_property>>> cases{
index 1134029059acb32990a92253a52ca5524109398b..3353382e7e497325e695145474679d46b0682c54 100644 (file)
@@ -76,7 +76,9 @@ public:
 
 namespace rspamd::css {
 
-
+/**
+ * Class that is designed to hold css declaration (a set of rules)
+ */
 class css_declarations_block {
 public:
        using rule_shared_ptr = std::shared_ptr<css_rule>;
@@ -96,9 +98,15 @@ public:
                return rules;
        }
 
+       /**
+        * Returns if a declaration block has some property
+        * @param prop
+        * @return
+        */
        auto has_property(const css_property &prop) const -> bool {
                return (rules.find(css_rule{prop}) != rules.end());
        }
+
 private:
        robin_hood::unordered_flat_set<rule_shared_ptr, rule_shared_hash, rule_shared_eq> rules;
 };