From 0d8073016bf214439d566fbf306e526780da11e9 Mon Sep 17 00:00:00 2001 From: Hannah Okwelum Date: Tue, 6 Aug 2024 15:25:41 +0100 Subject: [PATCH] Fix parse error when opacity is set to zero to alpha() function 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 --- lib/Less/Parser.php | 2 +- test/Fixtures/less.php/css/T371606-alpha-zero-error.css | 3 +++ test/Fixtures/less.php/less/T371606-alpha-zero-error.less | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 test/Fixtures/less.php/css/T371606-alpha-zero-error.css create mode 100644 test/Fixtures/less.php/less/T371606-alpha-zero-error.less diff --git a/lib/Less/Parser.php b/lib/Less/Parser.php index ef8a8164..c788e153 100644 --- a/lib/Less/Parser.php +++ b/lib/Less/Parser.php @@ -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' ); } diff --git a/test/Fixtures/less.php/css/T371606-alpha-zero-error.css b/test/Fixtures/less.php/css/T371606-alpha-zero-error.css new file mode 100644 index 00000000..5656bcf7 --- /dev/null +++ b/test/Fixtures/less.php/css/T371606-alpha-zero-error.css @@ -0,0 +1,3 @@ +.alpha { + filter: alpha(opacity=0); +} diff --git a/test/Fixtures/less.php/less/T371606-alpha-zero-error.less b/test/Fixtures/less.php/less/T371606-alpha-zero-error.less new file mode 100644 index 00000000..0c7fd30d --- /dev/null +++ b/test/Fixtures/less.php/less/T371606-alpha-zero-error.less @@ -0,0 +1,3 @@ +.alpha { + filter: alpha(opacity=0); + }