Skip to main content

Bug Tracker

Side navigation

#13070 closed bug (fixed)

Opened December 18, 2012 07:36AM UTC

Closed December 21, 2012 02:57AM UTC

filter()/is() does not work correctly with attribute equals selector which contains special characters

Reported by: caikanxp@gmail.com Owned by: gibson042
Priority: high Milestone: 1.9
Component: selector Version: 1.8.3
Keywords: Cc:
Blocked by: Blocking:
Description

filter()/is() does not work correctly with attribute equals selector which contains special characters.

Windows XP SP3.

Chrome 23.

<div></div>
<div></div>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script type="text/javascript">
<!--
var v1 = '\\\\';
var v2 = '"';
var v3 = '\\\\"';
$('div').attr({a1: v1, a2: v2, a3: v3});
var s1 = '[a1="\\\\\\\\"]'; // [a1="\\\\"]
var s2 = '[a2="\\\\""]'; // [a2="\\""]
var s3 = '[a3="\\\\\\\\\\\\""]'; // [a3="\\\\\\""]
var $q = $(s3); // works correctly
console.log($q.length); // 2
console.log($q.filter(s1).length); // 2
console.log($q.is(s1)); // true
console.log($q.filter(s2).length); // 2
console.log($q.is(s2)); // true
// the result is wrong when jQuery contains more then one element
console.log($q.filter(s3).length); // 0, should be 2
console.log($q.is(s3)); // false, should be true
// the result is right when jQuery contains only one element
console.log($q.eq(0).is(s1)); // result: true
console.log($q.eq(0).is(s2)); // result: true
console.log($q.eq(0).is(s3)); // result: true
//-->
</script>

Attachments (0)
Change History (3)

Changed December 18, 2012 09:23AM UTC by caikanxp@gmail.com comment:1

Here is the jsFiddle test case: http://jsfiddle.net/zR7xQ/

Changed December 19, 2012 02:06PM UTC by gibson042 comment:2

component: unfiledselector
milestone: None1.9
owner: → gibson042
priority: undecidedhigh
status: newassigned

Changed December 21, 2012 02:57AM UTC by Richard Gibson comment:3

resolution: → fixed
status: assignedclosed

Fix #13070: better unescaping logic in Sizzle

Changeset: 00bbbe207555d3aa9d7716bb9fc6d4e4f4bcbf1e