Uploaded image for project: 'Batik'
  1. Batik
  2. BATIK-848

CSS Parser: comment handling in wrong order

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Resolution: Unresolved
    • 1.8
    • None
    • CSS
    • None
    • Operating System: All
      Platform: All

    Description

      There is the method comment(String text) in the class org.w3c.css.sac.DocumentHandler, which is called by the CSS Parser every time a comment is found.

      But this is happening at the wrong time!
      Lets consider the following CSS:

      === CSS START ===

      • { color: #ff0000; /* comment 1 */ } /* comment 2 */ === CSS END === I'm using an implementation of DocumentHandler that has got a log() method, which can output every method call on the DocumentHandler. So this is the output for the CSS stated above: === startDocument === startSelector [ * ] property color := RGBCOLOR INT 255, COMMA, INT 0, COMMA, INT 0 /* comment 1 */ /* comment 2 */ endSelector [ * ] ___ endDocument ___ As you can see, "comment 2" is reported before endSelector() is called. In the right way, the output is supposed to be: === startDocument === startSelector [ * ] property color := RGBCOLOR INT 255, COMMA, INT 0, COMMA, INT 0 /* comment 1 */ endSelector [ * ] /* comment 2 */ ___ endDocument ___ I think the bug is in the Parser method parseStyleDeclaration(boolean inSheet). There, it is checked in a switch-case statement if "current" is a right curly brace (}

        ). So at this moment the right curly brace was detected, and now any further parsing/scanning action should only be after the Parser has called the method endSelector() on the DocumentHandler.

      But instead, it's followed by the statement nextIgnoreSpaces(), that goes on parsing/scanning the input and so comments are detected and reported to the DocumentHandler. And only afterwards endSelector() is called on the DocumentHandler.

      Very likely, this causes other problems with method calls on DocumentHandler as well, because parseStyleDeclaration(boolean inSheet) is used by the following Parser methods:
      protected void parseRuleSet();
      protected void parsePageRule();
      protected void parseFontFaceRule();
      protected void parseStyleDeclarationInternal();

      Attachments

        Activity

          People

            batik-dev@xmlgraphics.apache.org Batik Developer's Mailing list
            mathias.schaeffner@googlemail.com Mathias Schaeffner
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: