Skip to content

Commit

Permalink
Merge pull request #5 from sevenval/fix-handling-of-cdo-and-cdc-tokens
Browse files Browse the repository at this point in the history
Fix handling of CDO (<!--) and CDC (-->) tokens
  • Loading branch information
rcanavan authored Nov 8, 2017
2 parents f1392da + 5ab4c71 commit 121573e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
16 changes: 16 additions & 0 deletions extcss3/minifier/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,22 @@ extcss3_rule *extcss3_create_tree(extcss3_token **token, extcss3_token *max, uns
return tree;
}
}
// Pseudo-rule for <CDO> and <CDC> tokens in a non top-level
else if (((*token)->type == EXTCSS3_TYPE_CDO) || ((*token)->type == EXTCSS3_TYPE_CDC)) {
// See § 5.4.1.: https://www.w3.org/TR/css-syntax-3/#consume-a-list-of-rules
if (level > 0) {
rule->base_selector = rule->last_selector = *token;

// Fork the next rule
if (EXTCSS3_SUCCESS != _extcss3_tree_fork_rule(&rule, error)) {
return _extcss3_set_error_code(error, *error, tree);
}
}

*token = (*token)->next;

continue;
}

// Pseudo-rule for the <eof> token
if ((*token)->type == EXTCSS3_TYPE_EOF) {
Expand Down
4 changes: 4 additions & 0 deletions tests/minify_special_cases.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ var_dump($oProcessor->minify($sCSS));
$sCSS = ':not( x ) foo {a:b;}';
var_dump($oProcessor->minify($sCSS));

$sCSS = ' <!-- @media screen { <!-- x { a:b; } --> } --> ';
var_dump($oProcessor->minify($sCSS));

?>
===DONE===
--EXPECT--
Expand All @@ -50,4 +53,5 @@ string(105) "x{content:'\A\B'}y{background:url('wallpaper.jpg')}#\31st{color:red
string(10) "x{y:1px\9}"
string(48) "@media(min-width:30em)and (max-height:60em){a:b}"
string(16) ":not(x) foo{a:b}"
string(28) "@media screen{<!--x{a:b}-->}"
===DONE===

0 comments on commit 121573e

Please sign in to comment.