Side navigation
#14773 closed bug (fixed)
Opened February 07, 2014 11:20PM UTC
Closed March 05, 2014 02:50AM UTC
load() with selector doesn't work
Reported by: | edewata@redhat.com | Owned by: | dmethvin |
---|---|---|---|
Priority: | high | Milestone: | 1.11.1/2.1.1 |
Component: | ajax | Version: | 1.11.0 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Loading a URL that contains a selector doesn't work because there seems to be a parsing error.
For example:
div.load("page.html #content");
The selector should have been just the "#content" but the following jQuery code does not trim the space before the selector, producing " #content".
9981: off = url.indexOf(" "); 9983: if ( off >= 0 ) { 9984: selector = url.slice( off, url.length ); 9985: url = url.slice( 0, off ); 9986: }
When the selector is processed, it doesn't match the following regular expression because of the extra space, so the load() does not produce any result.
724: rquickExpr = /^(?:#([\\w-]+)|(\\w+)|\\.([\\w-]+))$/, 797: if ( (match = rquickExpr.exec( selector )) ) { 798: // Speed-up: Sizzle("#ID") 799: if ( (m = match[1]) ) {
Attachments (0)
Change History (5)
Changed February 18, 2014 11:01PM UTC by comment:1
component: | unfiled → ajax |
---|---|
milestone: | None → 1.11.1 |
priority: | undecided → high |
status: | new → open |
Changed February 24, 2014 04:57AM UTC by comment:2
Before:
''var selector, response, type,
self = this,
off = url.indexOf(" ");
if ( off >= 0 ) {
selector = url.slice( off, url.length );
url = url.slice( 0, off );
}''
After:
''var selector, response, type,
self = this,
off = url.indexOf(" ");
if ( off >= 0 ) {
selector = url.slice( off+1, url.length );
url = url.slice( 0, off );
}''
slice and indexOf both methods work on indexing of the string, where indexing of the string start from 0.
Here we didn't considering one extra char which is space. If we leave an extra char space in slice method. It will work fine.
var str = "Hello world!";
var res = str.slice(1,5);
it will return "ello".
Changed March 04, 2014 02:38AM UTC by comment:3
owner: | → dmethvin |
---|---|
status: | open → assigned |
Changed March 04, 2014 02:42PM UTC by comment:4
milestone: | 1.11.1 → 1.11.1/2.1.1 |
---|
Yep. I assume this was missed because it worked before we put in xss prevention in 1.8.