Skip to content

CSS minifier does not properly handle rule nesting #11

@mrokitka

Description

@mrokitka

https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_nesting/Using_CSS_nesting

Using the latest (1.3) release, java.lang.ArrayIndexOutOfBoundsException will be thrown when parsing some nested CSS rules.

For example, given the following CSS:

@media screen and (min-width:985px) and (max-width:1044px) {
  .deals-container {
    header.articleHeader {
      margin-left: 10px;    
    }  
  }
}

The following exception will be thrown:

java.lang.ArrayIndexOutOfBoundsException: Index 4 out of bounds for length 4
at net.logicsquad.minifier.css.CSSMinifier$Selector.(CSSMinifier.java:209)
at net.logicsquad.minifier.css.CSSMinifier.minify(CSSMinifier.java:147)

Since:

parts[0] = @media screen and (min-width:985px) and (max-width:1044px)
parts[1] = .deals-container
parts[2] = header.articleHeader
parts[3] = margin-left:10px;

parts[i + 1] = parts[i + 1].trim(); //CSSMinifier.java:209 - throws ArrayIndexOutOfBoundsException as parts[4] is beyond end of array when i == 3

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingenhancementNew feature or request

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions