Skip to content

Commit d32f99b

Browse files
Calme1709AtkinsSJ
authored andcommitted
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)`
1 parent 1977a97 commit d32f99b

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSMathFunctions.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,10 @@ RefPtr<CalculationNode const> Parser::parse_math_function(Function const& functi
417417
parameter_index++;
418418
});
419419

420+
function_generator.append(R"~~~(
421+
if (argument_index < arguments.size())
422+
return nullptr;
423+
)~~~");
420424
// Generate the call to the constructor
421425
function_generator.append(" return @name:titlecase@CalculationNode::create("sv);
422426
parameter_index = 0;

Tests/LibWeb/Text/expected/wpt-import/css/css-values/exp-log-invalid.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ Harness status: OK
22

33
Found 48 tests
44

5-
46 Pass
6-
2 Fail
5+
48 Pass
76
Pass e.style['opacity'] = "exp()" should not set the property value
87
Pass e.style['opacity'] = "exp( )" should not set the property value
98
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
1817
Pass e.style['opacity'] = "log()" should not set the property value
1918
Pass e.style['opacity'] = "log( )" should not set the property value
2019
Pass e.style['opacity'] = "log(,)" should not set the property value
21-
Fail e.style['opacity'] = "log(1, )" should not set the property value
20+
Pass e.style['opacity'] = "log(1, )" should not set the property value
2221
Pass e.style['opacity'] = "log(, 1)" should not set the property value
2322
Pass e.style['opacity'] = "log(1 + )" should not set the property value
2423
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
5150
Pass e.style['opacity'] = "log(1, 0deg)" should not set the property value
5251
Pass e.style['opacity'] = "log(1, 0Hz)" should not set the property value
5352
Pass e.style['opacity'] = "log(1, 0dpi)" should not set the property value
54-
Fail e.style['opacity'] = "log(1, 0fr)" should not set the property value
53+
Pass e.style['opacity'] = "log(1, 0fr)" should not set the property value

0 commit comments

Comments
 (0)