Skip to content

Commit

Permalink
Don't strip } when stripping empty tags preceeded by 2 }s
Browse files Browse the repository at this point in the history
Fixes #92
  • Loading branch information
matthiasmullie committed Jan 11, 2016
1 parent bf87a5c commit 140c714
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/CSS.php
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ protected function shortenZeroes($content)
*/
protected function stripEmptyTags($content)
{
return preg_replace('/(^|\})[^\{]+\{\s*\}/', '\\1', $content);
return preg_replace('/(^|\})[^\{\}]+\{\s*\}/', '\\1', $content);
}

/**
Expand Down
21 changes: 21 additions & 0 deletions tests/css/CSSTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,27 @@ public function dataProvider()
'@media only screen and (-webkit-min-device-pixel-ratio:1.5),only screen and (min--moz-device-pixel-ratio:1.5),only screen and (min-device-pixel-ratio:1.5){#fancybox-loading,.fancybox-close,.fancybox-prev span,.fancybox-next span{background-image:url(/path/to/image.png);background-size:44px 152px}#fancybox-loading div{background-image:url(/path/to/image.gif);background-size:24px 24px}}',
);

// https://github.com/matthiasmullie/minify/issues/92
$tests[] = array(
'@media (min-width:320px) {
/* smartphones, iPhone, portrait 480x320 phones */
p {
background-color: red;
}
}
@media (min-width:1025px) {
/* big landscape tablets, laptops, and desktops */
/* LEFT EMPTY OF ANY SELECTORS */
}
@media (min-width:1281px) {
/* hi-res laptops and desktops */
p {
background-color: blue;
}
}',
'@media (min-width:320px){p{background-color:red}}@media (min-width:1281px){p{background-color:blue}}',
);

return $tests;
}

Expand Down

0 comments on commit 140c714

Please sign in to comment.