#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
comment:2 Changed 13 years ago by
Component: | unfiled → selector |
---|---|
Keywords: | regression needsreview added |
Milestone: | 1.5 → 1.4.5 |
Priority: | undecided → high |
Status: | new → open |
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.
comment:3 Changed 13 years ago by
Owner: | set to jitter |
---|---|
Status: | open → assigned |
comment:5 Changed 13 years ago by
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!
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 follow-up: 7 Changed 13 years ago by
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 Changed 13 years ago by
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
Blocking: | 7620 removed |
---|
comment:21 Changed 12 years ago by
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:23 Changed 12 years ago by
Milestone: | 1.4.5 → 1.5 |
---|
Move fixed tickets to appropriate milestone
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