Bug Tracker

Modify

Ticket #10270 (closed bug: fixed)

Opened 22 months ago

Last modified 12 months ago

(any) attribute selector does not match if value contains '\'

Reported by: mamille2@… Owned by: timmywil
Priority: low Milestone: 1.next
Component: selector Version: 1.6.3
Keywords: Cc:
Blocking: Blocked by:

Description

If an attribute selector value contains '\', it will never match. For instance, given the following input DOM:

<message xmlns='jabber:client'
                 type='groupchat'
                 from='some\20room@conference.example.com/juliet'
                 to='romeo@montegue.net/garden'>
  <body></body>
</message>

The following selector fails with 1.6.3 (but works with 1.4.4):

$(dom.ownerDocument).find("message[from^='some\20room@conference.example.com']")
  • jQuery-1.6.3: returns []
  • jQuery-1.4.4: returns [dom]

Also tried "=", "*=", "~=", "$=", and "|=" with the same results ("!=" with jQuery-1.6.3 returning [dom] and 1.4.4 returning []).

Change History

comment:1 Changed 21 months ago by mamille2@…

It appears that the various preFilter functions unconditionally remove '\' from all parts of the expression, regardless of what follows or in what part of the expression it is.

comment:2 Changed 21 months ago by mamille2@…

Sorry, forgot to add platforms affected:

  • Chrome 13
  • Safari 5.1
  • Firefox 6
  • IE 8
  • IE 9

comment:3 Changed 21 months ago by addyosmani

  • Owner set to mamille2@…
  • Priority changed from undecided to low
  • Status changed from new to pending
  • Component changed from unfiled to selector

Thanks for submitting a ticket to the jQuery bug tracker. Could you kindly also submit a complete test case on jsFiddle.net that reproduces all of the behaviour you've described? If you can ensure that it covers any of the cases you've mentioned this will make it easier for us to evaluate and confirm the issue across multiple browsers before we discuss how to correct it.

comment:4 Changed 21 months ago by mamille2@…

  • Status changed from pending to new

jsFiddle test case at < http://jsfiddle.net/HFx3e/1/>.

Also, a potential patch to Sizzle available at < https://github.com/jquery/sizzle/pull/72>.

comment:5 Changed 21 months ago by timmywil

  • Status changed from new to open
  • Milestone changed from None to 1.next

comment:6 Changed 12 months ago by timmywil

  • Owner changed from mamille2@… to timmywil
  • Status changed from open to assigned

comment:7 Changed 12 months ago by timmywil

  • Status changed from assigned to closed
  • Resolution set to fixed

Update Sizzle: fixes a bug dealing with backslashes in selectors. Fixes #10270.

Changeset: 868a9cea08579ae635ce258aed3062705a8d2379

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.