https://issues.apache.org/bugzilla/show_bug.cgi?id=45663
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: [email protected]
ReportedBy: [EMAIL PROTECTED]
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();
--
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]