Migrate from GitHub to SourceForge with this tool. Check out all of SourceForge's recent improvements.
Close

#69 CSSParser has css order bug

0.9.21
closed
RBRi
None
1
2016-11-28
2016-11-24
JiWon Hong
No

When CSS is like this

@import url(http://fonts.googleapis.com/css?family=Open+Sans:400,600,300);
@charset "UTF-8";

div#abc {~~~~~~~~~~}
div#def {~~~~~~~~~~}

It gives a error.
null [2:1] Error in rule. (Invalid token "@charset". Was expecting one of: <S>, <IDENT>, "", ".", ":", "*", "[", <HASH>, <IMPORT_SYM>, <PAGE_SYM>, <MEDIA_SYM>, <FONT_FACE_SYM>, <ATKEYWORD>.)
null [2:1]
Ignoring the whole rule.

And CSS Parser can parse from second css. If CSS is above example, CSS Parser can parse from 'div#def'. 'div#abc' is ignored.

But when order changed like this

@charset "UTF-8";
@import url(http://fonts.googleapis.com/css?family=Open+Sans:400,600,300);

div#abc {~~~~~~~~~~}
div#def {~~~~~~~~~~}

It doesn't give error!
Please fix this bug as soon as possible.

Thanks.

Discussion

  • RBRi

    RBRi - 2016-11-24

    I think you are wrong here. The charset rule has to be the first stuff inside the file.
    See https://developer.mozilla.org/de/docs/Web/CSS/@charset for more.
    However i have done some improvments on error processing. No the parser restarts always with the first rule after the misplaced charset rule.
    Hope that helps - a new snapshot build is available.

     
  • RBRi

    RBRi - 2016-11-24
    • status: open --> pending
    • assigned_to: RBRi
     
  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous

    Anonymous - 2016-11-25

    I'm using maven. In maven, 0.9.21 version is missing. How can I get cssparser-0.9.21.jar?

     
    • RBRi

      RBRi - 2016-11-25

      Chance the Version in pom.xml to 0.9.22-SNAPSHOT

       
      Last edit: RBRi 2016-11-27
  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous

    Anonymous - 2016-11-25

    I used cssparser dependency like this. this works.
    <dependency>
    <groupId>net.sourceforge.cssparser</groupId>
    <artifactId>cssparser</artifactId>
    <version>0.9.20</version>
    </dependency>

    But like this, it makes error.
    error message is 'Missing artifact net.sourceforge.cssparser:cssparser:jar:0.9.22-SNAPSHOT'

    <dependency>
    <groupId>net.sourceforge.cssparser</groupId>
    <artifactId>cssparser</artifactId>
    <version>0.9.22-SNAPSHOT</version>
    </dependency>

    Is it wrong? Please check my dependency.

     
    • RBRi

      RBRi - 2016-11-25

      Sorry my fault. 0.9.21-SNAPSHOT

       
      Last edit: RBRi 2016-11-27
  • RBRi

    RBRi - 2016-11-27

    Is it working now?

     
  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous

    Anonymous - 2016-11-27

    0.9.21-SNAPSHOT version makes 'Missing artifact net.sourceforge.cssparser:cssparser:jar:0.9.21-SNAPSHOT' error, too...

     
    Last edit: Anonymous 2016-11-28
  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous

    Anonymous - 2016-11-28

    0.9.21-SNAPSHOT version makes 'Missing artifact net.sourceforge.cssparser:cssparser:jar:0.9.21-SNAPSHOT' error, too...

     
  • RBRi

    RBRi - 2016-11-28

    There is some documentation about getting the latest snapshot.
    http://htmlunit.sourceforge.net/gettingLatestCode.html

     
  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous

    Anonymous - 2016-11-28

    I applied snapshot version. But css right after misplaced charset rule is still ignored.
    when my css is like this.

    @import url(http://fonts.googleapis.com/css?family=Open+Sans:400,600,300);
    @charset "UTF-8";

    div#abc {~~~~~~~~~~}
    div#def {~~~~~~~~~~}

    and CSSParser gives like this

    @import url(http://fonts.googleapis.com/css?family=Open+Sans:400,600,300);
    div#def {~~~~~~~~~~}

    'div#abc' rule is ignored. How can I handle this?

     
  • RBRi

    RBRi - 2016-11-28

    Strange, that is exactly what i have fixed. Have a look at SACParserCSS3Test.charsetImportBefore(). Can you please provide a small code sample.

     
  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous

    Anonymous - 2016-11-28

    This is a sample code.

    @import url(http://fonts.googleapis.com/css?family=Open+Sans:400,600,300);
    @charset "UTF-8";
    / Base Styles /

    menu,

    menu ul,

    menu li,

    menu a {

    margin: 0;
    padding: 0;
    border: 0;
    list-style: none;
    font-weight: normal;
    text-decoration: none;
    line-height: 1;
    font-family: 'Open Sans', sans-serif;
    font-size: 14px;
    position: relative;
    }

    menu a {

    line-height: 1.5;
    }

     
    • RBRi

      RBRi - 2016-11-28

      OK, you found another issues - the problem is in the skip code that is not able to deal with the comment.
      This is fixed now and a new snapshot is available. Please try.

       
  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous

    Anonymous - 2016-11-28

    Working great! Thanks :-)

     
  • RBRi

    RBRi - 2016-11-28
    • status: pending --> closed
     

Anonymous
Anonymous

Cancel  Add attachments