Bugs item #3035310, was opened at 2010-07-27 16:07
Message generated for change (Comment added) made by henryju
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=497982&aid=3035310&group_id=61302
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
>Category: HtmlUnit plugin
Group: None
>Status: Closed
>Resolution: Rejected
Priority: 5
Private: No
Submitted By: Felipe Duarte (fcduarte83)
Assigned to: Nobody/Anonymous (nobody)
Summary: CSSStyleSheetImpl insertRule method throws NPE
Initial Comment:
Hi Folks,
I found a bug on CSS Parser.. The class CSSStyleSheetImpl has the following
code on insertRule method after line 147:
try {
InputSource is = new InputSource(new StringReader(rule));
CSSOMParser parser = new CSSOMParser();
parser.setParentStyleSheet(this);
CSSRule r = parser.parseRule(is);
if (getCssRules().getLength() > 0) {
// We need to check that this type of rule can legally go into
// the requested position.
int msg = -1;
if (r.getType() == CSSRule.CHARSET_RULE) {
// Index must be 0, and there can be only one charset rule
if (index != 0) {
msg = DOMExceptionImpl.CHARSET_NOT_FIRST;
} else if (getCssRules().item(0).getType()
== CSSRule.CHARSET_RULE) {
msg = DOMExceptionImpl.CHARSET_NOT_UNIQUE;
}
} else if (r.getType() == CSSRule.IMPORT_RULE) {
// Import rules must preceed all other rules (except
// charset rules)
if (index <= getCssRules().getLength()) {
for (int i = 0; i < index; i++) {
int rt = getCssRules().item(i).getType();
if ((rt != CSSRule.CHARSET_RULE)
|| (rt != CSSRule.IMPORT_RULE)) {
msg = DOMExceptionImpl.IMPORT_NOT_FIRST;
break;
}
}
}
}
if (msg > -1) {
throw new DOMExceptionImpl(
DOMException.HIERARCHY_REQUEST_ERR,
msg);
}
}
// Insert the rule into the list of rules
((CSSRuleListImpl)getCssRules()).insert(r, index);
...
If this line "CSSRule r = parser.parseRule(is);" returns null, then we will get
a NPE on this code: "if (r.getType() == CSSRule.CHARSET_RULE) {" ..
I think this must have a protection such like "if (r != null) {...}"
The string to simulate this bug is "ul[class^="udm"]
li{left:0;position:static;}" with have to be passed to attribute "rule" ..
Cheers,
Felipe
----------------------------------------------------------------------
>Comment By: Julien HENRY (henryju)
Date: 2010-10-19 16:05
Message:
Please report this bug to HtmlUnit team (htmlunit.sourceforge.net). We are
only responsible for the jwebunit code.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=497982&aid=3035310&group_id=61302
------------------------------------------------------------------------------
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev
_______________________________________________
JWebUnit-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-development