Bugs item #3035310, was opened at 2010-07-27 11:07
Message generated for change (Tracker Item Submitted) made by fcduarte83
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: Core API
Group: None
Status: Open
Resolution: None
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


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=497982&aid=3035310&group_id=61302

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share 
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
JWebUnit-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-development

Reply via email to