Skip to content

Commit b88dcc6

Browse files
Make sure math methods extraction checks for word boundaries
Otherwise, 'max' could be confused with 'minmax' Fixes #356
1 parent 227f190 commit b88dcc6

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/CSS.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ protected function stripWhitespace($content)
685685
protected function extractMath()
686686
{
687687
$functions = array('calc', 'clamp', 'min', 'max');
688-
$pattern = '/('. implode('|', $functions) .')(\(.+?)(?=$|;|})/m';
688+
$pattern = '/\b('. implode('|', $functions) .')(\(.+?)(?=$|;|})/m';
689689

690690
// PHP only supports $this inside anonymous functions since 5.4
691691
$minifier = $this;

tests/css/CSSTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,12 @@ public function dataProvider()
833833
'.space-x-4>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-right:calc(1rem * var(--tw-space-x-reverse));margin-left:calc(1rem * calc(1 - var(--tw-space-x-reverse)))}',
834834
);
835835

836+
// https://github.com/matthiasmullie/minify/issues/356
837+
$tests[] = array(
838+
'.testclass{ grid-template-columns:minmax(0,1fr) minmax(0,1fr) minmax(0,1fr); }',
839+
'.testclass{grid-template-columns:minmax(0,1fr) minmax(0,1fr) minmax(0,1fr)}',
840+
);
841+
836842
return $tests;
837843
}
838844

0 commit comments

Comments
 (0)