Opened 7 years ago

Closed 5 years ago

#15627 closed defect (fixed)

Query interprets ">" character in attribute value selector incorrectly

Reported by: James Thomas Owned by: Kris Zyp
Priority: high Milestone: 1.8.7
Component: Query Version: 1.7.3
Keywords: Cc:
Blocked By: Blocking:

Description (last modified by James Thomas)

Ran into the following issue using the dojo/query module with an attribute value selector query.

We have a DOM node with the following attributes in our application: <div rowid="32115-<Person>-Missing" ></div>

Querying the DOM for the following selector yields no nodes using dojo/query: query("[rowid='32115-<Person>-Missing']") However, using the native QSA method does return the node.

Digging into the code, it appears the problem lies here:

	var getQueryFunc = function(query, forceDOM){
		//Normalize query. The CSS3 selectors spec allows for omitting spaces around
		//infix operators, >, ~ and +
		//Do the work here since detection for spaces is used as a simple "not use QSA"
		//test below.
		query = query.replace(infixSpaceRe, infixSpaceFunc);

		if(qsaAvail){
			// if we've got a cached variant and we think we can do it, run it!
			var qsaCached = _queryFuncCacheQSA[query];
			if(qsaCached && !forceDOM){ return qsaCached; }
		}

This regular expression turns the selector string from: "[rowid='32115-<Person >-Missing']" to: "[rowid='32115-<Person > -Missing']"

which then doesn't match our node....

Looking through the related HTML[1] and CSS[2] specs, I can't see any indication that an attribute value with a ">" character is not valid.

Can we change that regex to ignore those characters when they are inside quotes?

[1] - http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#attribute-value-(double-quoted)-state

[2] - http://www.w3.org/TR/css3-selectors/#attribute-selectors

Change History (4)

comment:1 Changed 7 years ago by James Thomas

Description: modified (diff)

comment:2 Changed 7 years ago by dylan

Milestone: tbd1.9
Priority: undecidedhigh

comment:3 Changed 6 years ago by bill

Milestone: 1.91.10

Bumping this ticket since we are past the deadline for the 1.9RC. The fix can be put into 1.9.1 too, if desired.

comment:4 Changed 5 years ago by Kris Zyp

Milestone: 1.101.8.7
Resolution: fixed
Status: newclosed

I believe this is essentially the same bug as #10651, and fixed by https://github.com/dojo/dojo/commit/a1fff605c3ed1b7e6173983ae74775ff1285f8ac.

Note: See TracTickets for help on using tickets.