Skip to content

Commit

Permalink
Fix parse error when opacity is set to zero to alpha() function
Browse files Browse the repository at this point in the history
Bug was as a result of matchReg returning "0" (zero string) when
opacity is set to zero. PHP sees this as false and ends up throwing
a Less_Exception_Parser.

Bug: T371606
Change-Id: I75704789eac249e48336898730a573ed1cddafef
  • Loading branch information
Hannah Okwelum authored and Krinkle committed Aug 6, 2024
1 parent c28be8d commit 0d80730
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Less/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -2134,7 +2134,7 @@ private function parseAlpha() {
}

$value = $this->matchReg( '/\\G[0-9]+/' );
if ( !$value ) {
if ( $value === null ) {
$value = $this->expect( 'parseEntitiesVariable', 'Could not parse alpha' );
}

Expand Down
3 changes: 3 additions & 0 deletions test/Fixtures/less.php/css/T371606-alpha-zero-error.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.alpha {
filter: alpha(opacity=0);
}
3 changes: 3 additions & 0 deletions test/Fixtures/less.php/less/T371606-alpha-zero-error.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.alpha {
filter: alpha(opacity=0);
}

0 comments on commit 0d80730

Please sign in to comment.