diff options
author | Andreas Kling <kling@serenityos.org> | 2020-06-23 20:06:45 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-06-23 20:06:45 +0200 |
commit | d0312f6208cd20c121d8e0cdc63379407ea2b2d9 (patch) | |
tree | 61c48a9cbeab1b2734807fa80ddf99f54f52dfbc | |
parent | 86098505ecd6162c633b5b3c0a2d153de86a2983 (diff) | |
download | serenity-d0312f6208cd20c121d8e0cdc63379407ea2b2d9.zip |
LibWeb: Handle empty inputs to the CSS parser
Empty inputs -> empty outputs.
-rw-r--r-- | Libraries/LibWeb/Parser/CSSParser.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Libraries/LibWeb/Parser/CSSParser.cpp b/Libraries/LibWeb/Parser/CSSParser.cpp index 490f0c15ab..d7b1ef3e3e 100644 --- a/Libraries/LibWeb/Parser/CSSParser.cpp +++ b/Libraries/LibWeb/Parser/CSSParser.cpp @@ -859,12 +859,16 @@ Optional<Selector> parse_selector(const StringView& selector_text) RefPtr<StyleSheet> parse_css(const StringView& css) { + if (css.is_empty()) + return StyleSheet::create({}); CSSParser parser(css); return parser.parse_sheet(); } RefPtr<StyleDeclaration> parse_css_declaration(const StringView& css) { + if (css.is_empty()) + return StyleDeclaration::create({}); CSSParser parser(css); return parser.parse_standalone_declaration(); } |