srctree

Robin Linden parent 29964344 f96938e3
css: Ignore `@import` at-rules

Without this, any @import at-rules are likely to kill parsing of therest of the document.

inlinesplit
css/parser.cpp added: 15, removed: 2, total 13
@@ -314,6 +314,14 @@ StyleSheet Parser::parse_rules() {
return style;
}
 
if (kind == "@import") {
std::ignore = consume_while([](char c) { return c != ';'; });
consume_char(); // ;
skip_whitespace_and_comments();
spdlog::warn("Encountered unhandled import at-rule", *kind);
continue;
}
 
spdlog::warn("Encountered unhandled {} at-rule", *kind);
 
skip_whitespace_and_comments();
 
css/parser_test.cpp added: 15, removed: 2, total 13
@@ -1257,5 +1257,10 @@ int main() {
a.expect(css::parse("@charset 'shi").rules.empty()); //
});
 
s.add_test("parser: @import", [](etest::IActions &a) {
a.expect_eq(css::parse("@import 'test.css'; p { font-size: 3px; }").rules.at(0),
css::Rule{{"p"}, {{css::PropertyId::FontSize, "3px"}}});
});
 
return s.run();
}