You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by bu...@apache.org on 2008/08/21 14:09:08 UTC
DO NOT REPLY [Bug 45663] New: CSS Parser: comment handling in wrong
order
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: 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
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: batik-dev-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-help@xmlgraphics.apache.org
DO NOT REPLY [Bug 45663] CSS Parser: comment handling in wrong order
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45663
--- Comment #1 from Mathias Schaeffner <ma...@googlemail.com> 2009-03-16 15:27:53 PST ---
Has anyone investigated this bug yet?
Can anyone confirm this misbehavior?
Is there a Batik developer, who'd like to fix that issue?
I'm using the Batik CSS Parser and my application requires correct parsing of
comments included in the CSS file.
So I really appreciate any work about this.
--
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
DO NOT REPLY [Bug 45663] CSS Parser: comment handling in wrong order
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45663
Mathias Schaeffner <ma...@googlemail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
OS/Version|Linux |All
Platform|PC |All
--
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
DO NOT REPLY [Bug 45663] CSS Parser: comment handling in wrong order
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45663
--- Comment #2 from Helder Magalhães <he...@gmail.com> 2009-03-17 04:39:21 PST ---
(In reply to comment #1)
> I'm using the Batik CSS Parser and my application requires correct parsing of
> comments included in the CSS file.
To be honest, relying on correct comment parsing seems overall a risky decision
in the first place. I believe other implementations have suffered (or may still
suffer) from similar issues -- although can't currently remember which one(s)
in particular, I have some diffuse memories on this... But of course this is a
bug and should be fixed.
> So I really appreciate any work about this.
Patches are always welcome! :-) Given your detailed report, I'd inclusively
say you might potentially be the right person to propose a fix: Why not
checkout the trunk code [1] and and rehearse an attempt to correct this? ;-)
[1] http://xmlgraphics.apache.org/batik/download.cgi#Subversion+repository
--
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
DO NOT REPLY [Bug 45663] CSS Parser: comment handling in wrong order
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45663
--- Comment #3 from Cameron McCormack <ca...@apache.org> 2009-03-18 20:47:30 PST ---
(In reply to comment #1)
> Has anyone investigated this bug yet?
> Can anyone confirm this misbehavior?
If you could supply a short test case (standalone program) that exhibits the
problem, that would be helpful for testing.
I think the solution could be to make parseStyleDeclaration(boolean) not
consuming the "}" token, and for parseRuleSet() (and the others you identify)
to be responsible for consuming it.
--
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