Skip to content

Some csstidy declaration are not handle properly in ExtractStyleBlocks #357

@Wolfrank1149

Description

@Wolfrank1149

In csstidy, IMPORTANT_COMMENT ($this->_tidy->css['!'] in ExtractStyleBlocks) are declaired as string. But, when it goes trough ExtractStyleBlocks, it is transformed in an empty array while it should stay a string.

  • ExtractStyleBlocks.php line 317-319 where IMPORTANT_COMMENT is transform
    $new_decls[$selector] = $style;
}
$new_css[$k] = $new_decls;

The reason why it is reuse by csstidy where it expected to be a string and it cause an error because it is now an array.

  • class.csstidy_print.php line 352-355 where IMPORTANT_COMMENT is reuse in csstidy
if (isset($this->css['!'])) {
      $this->parser->_add_token(IMPORTANT_COMMENT, rtrim($this->css['!']), true);
      unset($this->css['!']);
}

Ex:

<style>
/*! important comment */
h1 {
  color: white;
  text-align: center;
}

/*! another important comment */
p {
  font-family: verdana;
  font-size: 20px;
}
</style>

After being parse by csstidy (ExtractStyleBlocks.php line 141), IMPORTANT_COMMENT looks like this: $this->_tidy->css['!'] = 'important comment\nanother important comment'

After being transform by ExtractStyleBlocks, IMPORTANT_COMMENT looks like this: $this->_tidy->css['!'] = []

It than cause an argument error rtrim(): Argument #1 ($string) must be of type string, array given when it is reuse by csstidy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions