Bug Tracker

Opened 13 years ago

Closed 13 years ago

Last modified 12 years ago

#7533 closed bug (fixed)

Problem with id containing a period

Reported by: kiequoo Owned by: jitter
Priority: high Milestone: 1.5
Component: selector Version: 1.4.4
Keywords: regression, needsreview Cc:
Blocked by: Blocking:

Description

When creating a jQuery object from a piece of html, if an id attribute within the HTML contains a period, this breaks the find command and it never returns a result. This is best seen in this example in jsFiddle: http://jsfiddle.net/2gHqc/ - when run with jQuery 1.4.4 the alert displays 0, in previous versions of jQuery it returns 1.

Change History (24)

comment:1 Changed 13 years ago by boushley

And having a period in the id is valid according to the W3 "ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".")." http://www.w3.org/TR/html401/types.html#type-name

comment:2 Changed 13 years ago by jitter

Component: unfiledselector
Keywords: regression needsreview added
Milestone: 1.51.4.5
Priority: undecidedhigh
Status: newopen

The issue is a bit more complex, as in HTML 5 basically everything is allowed as ID token.

A possible start/idea for a fix could be what I tried on this pull request.

Not sure if I catched all relevant characters in the regexp, please double check. I will update when necessary.

Last edited 13 years ago by jitter (previous) (diff)

comment:3 Changed 13 years ago by jitter

Owner: set to jitter
Status: openassigned

comment:4 Changed 13 years ago by addyosmani

#7619 is a duplicate of this ticket.

comment:5 Changed 13 years ago by jitter

Blocking: 7620 added

(In #7620) Thanks for taking the time to contribute to the jQuery project by writing a bug report and providing a testcase!

reduced test case

jQuery has sometimes issues when the id attribute contains meta characters. Here it is triggered as jQuery internally uses the present id attribute to speed up the search. Check on #7533 which (once fixed) should also fix this bug.

comment:6 Changed 13 years ago by anonymous

Having a non escaped period (.) maybe valid for the HTML attribute value but *not* the CSS selector. QSA is correct when it chokes on the non-escaped IDs. http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier

Because jQuery is dynamically constructing selectors it bares the responsibility of escaping them in those instances.

comment:7 in reply to:  6 Changed 13 years ago by jitter

Replying to anonymous:

QSA is correct when it chokes on the non-escaped IDs.

And nobody claims otherwise. That's why this ticket got accepted as valid and has a patch pending.

comment:8 Changed 13 years ago by jitter

Blocking: 7620 removed

comment:9 Changed 13 years ago by jitter

#7620 is a duplicate of this ticket.

comment:10 Changed 13 years ago by jitter

#7634 is a duplicate of this ticket.

comment:11 Changed 13 years ago by jitter

#7643 is a duplicate of this ticket.

comment:12 Changed 13 years ago by jitter

#7661 is a duplicate of this ticket.

comment:13 Changed 13 years ago by jitter

#7680 is a duplicate of this ticket.

comment:14 Changed 13 years ago by jitter

new pull request with the solution suggested by John Resig

Last edited 13 years ago by jitter (previous) (diff)

comment:15 Changed 13 years ago by john

Resolution: fixed
Status: assignedclosed

Landed.

comment:16 Changed 13 years ago by jitter

#7740 is a duplicate of this ticket.

comment:17 Changed 13 years ago by jitter

#7776 is a duplicate of this ticket.

comment:18 Changed 13 years ago by jitter

#7807 is a duplicate of this ticket.

comment:19 Changed 13 years ago by ajpiano

#7820 is a duplicate of this ticket.

comment:20 Changed 13 years ago by ajpiano

#7829 is a duplicate of this ticket.

comment:21 in reply to:  20 Changed 13 years ago by anonymous

Replying to ajpiano:

#7829 is a duplicate of this ticket.

#7829 is not a duplicate, please see the demo here: http://jsfiddle.net/QYUPQ/1/

You can compare it to: http://jsfiddle.net/QYUPQ/

comment:22 Changed 13 years ago by ajpiano

#7873 is a duplicate of this ticket.

comment:23 Changed 13 years ago by jitter

Milestone: 1.4.51.5

Move fixed tickets to appropriate milestone

comment:24 Changed 13 years ago by jitter

#8021 is a duplicate of this ticket.

Note: See TracTickets for help on using tickets.