xmlgraphics-batik-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 45663] New: CSS Parser: comment handling in wrong order
Date Thu, 21 Aug 2008 12:09:08 GMT

           Summary: CSS Parser: comment handling in wrong order
           Product: Batik
           Version: 2.0
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: CSS
        AssignedTo: batik-dev@xmlgraphics.apache.org
        ReportedBy: mathias.schaeffner@googlemail.com

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

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();

Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

To unsubscribe, e-mail: batik-dev-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-help@xmlgraphics.apache.org

View raw message