From 32e5d2131b7de14b720340f2aa20a9c5c467716a Mon Sep 17 00:00:00 2001 From: Paulo Medeiros Date: Thu, 12 Sep 2024 13:20:15 +0200 Subject: [PATCH] style: raise error if trailing unexpected tokens --- src/web/vaev-style/decls.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/web/vaev-style/decls.h b/src/web/vaev-style/decls.h index 2f87221..bd940ad 100644 --- a/src/web/vaev-style/decls.h +++ b/src/web/vaev-style/decls.h @@ -2,6 +2,8 @@ #include +#include "base.h" + namespace Vaev::Style { template @@ -36,7 +38,7 @@ Res

parseDeclaration(Css::Sst const &sst) { auto res = parseDeclarationValue(cursor); if (not res) { resDecl = res.none(); - return false; + return true; } resDecl = Ok(res.take()); @@ -46,6 +48,11 @@ Res

parseDeclaration(Css::Sst const &sst) { resDecl.unwrap().important = Important::YES; } + eatWhitespace(cursor); + if (not cursor.ended()) + resDecl = Error::invalidData("unknown tokens in content"); + + return true; });