LibWeb: Ensure all passed arguments are used when parsing math functions

This disallows things such as `log(1, foobar)` where we would previously
just skip over `foobar` and parse this as `log(1)`
This commit is contained in:
Callum Law 2025-10-22 17:27:08 +13:00 committed by Sam Atkins
parent 1977a976da
commit d32f99b16f
Notes: github-actions[bot] 2025-10-23 08:35:51 +00:00
2 changed files with 7 additions and 4 deletions

View file

@ -417,6 +417,10 @@ RefPtr<CalculationNode const> Parser::parse_math_function(Function const& functi
parameter_index++;
});
function_generator.append(R"~~~(
if (argument_index < arguments.size())
return nullptr;
)~~~");
// Generate the call to the constructor
function_generator.append(" return @name:titlecase@CalculationNode::create("sv);
parameter_index = 0;

View file

@ -2,8 +2,7 @@ Harness status: OK
Found 48 tests
46 Pass
2 Fail
48 Pass
Pass e.style['opacity'] = "exp()" should not set the property value
Pass e.style['opacity'] = "exp( )" should not set the property value
Pass e.style['opacity'] = "exp(,)" should not set the property value
@ -18,7 +17,7 @@ Pass e.style['opacity'] = "exp(1, , 2)" should not set the property value
Pass e.style['opacity'] = "log()" should not set the property value
Pass e.style['opacity'] = "log( )" should not set the property value
Pass e.style['opacity'] = "log(,)" should not set the property value
Fail e.style['opacity'] = "log(1, )" should not set the property value
Pass e.style['opacity'] = "log(1, )" should not set the property value
Pass e.style['opacity'] = "log(, 1)" should not set the property value
Pass e.style['opacity'] = "log(1 + )" should not set the property value
Pass e.style['opacity'] = "log(1 - )" should not set the property value
@ -51,4 +50,4 @@ Pass e.style['opacity'] = "log(1, 0s)" should not set the property value
Pass e.style['opacity'] = "log(1, 0deg)" should not set the property value
Pass e.style['opacity'] = "log(1, 0Hz)" should not set the property value
Pass e.style['opacity'] = "log(1, 0dpi)" should not set the property value
Fail e.style['opacity'] = "log(1, 0fr)" should not set the property value
Pass e.style['opacity'] = "log(1, 0fr)" should not set the property value