Bug Tracker

Opened 7 years ago

Closed 7 years ago

#12086 closed bug (invalid)

Checking value for null after using property of value. Method "attr"

Reported by: deltaplans@… Owned by: deltaplans@…
Priority: low Milestone: None
Component: attributes Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:

Description

Checking value for null after using property of value. There is next code (start from 2511 row) in current version (source code, but in min version code is same):

 attr: function( elem, name, value, pass ) {
                var ret, hooks, notxml,
                  nType = elem.nodeType;

		// don't get/set attributes on text, comment and attribute nodes
		if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
			return;
		}

For getting nType value used elem.nodeType, but elem didn't check for null before. It will checked after that (in the next rows). It seems that it should be lik this:


if ( !elem) return;

var ret, hooks, notxml,
                  nType = elem.nodeType;
 if(nType === 3 || nType === 8 || nType === 2 ) {
			return;
		}

Change History (5)

comment:1 Changed 7 years ago by dmethvin

Owner: set to deltaplans@…
Status: newpending

What code is this affecting? Since null is not an element it shouldn't be passed there.

comment:2 Changed 7 years ago by anonymous

ok, just I use jqGrid and it call this method with null value. I looked to version 1.5.2 and this have checking for null or undefined first here.

But anyway maybe it is right to do checking elem, and than get his property?

comment:3 Changed 7 years ago by addyosmani

Component: unfiledattributes
Priority: undecidedlow

null shouldn't be getting passed as an element reference to attr() and if jqGrid is doing this then they should be updating their code to perform checks on the input being passed through through the chain. imo, the current behavior shouldn't change. Garbage in, garbage out :)

comment:4 Changed 7 years ago by deltaplan

ok, thank you

comment:5 Changed 7 years ago by mikesherov

Resolution: invalid
Status: pendingclosed
Note: See TracTickets for help on using tickets.