Ticket #12635 (closed bug: fixed)
jquery 1.8.2 fails ajax calls in IE9 because it assumes cross domain when default port is in ajax url
| Reported by: | benjamin.haentjens@… | Owned by: | gibson042 |
|---|---|---|---|
| Priority: | high | Milestone: | 1.8.3 |
| Component: | ajax | Version: | 1.8.2 |
| Keywords: | Cc: | gibson042 | |
| Blocking: | Blocked by: |
Description
We upgraded from 1.7.2 to 1.8.2, and I was able to track down the offending javascript:
In version 1.7.2 we had this to test crossdomain:
crossDomain = !!( parts && ( parts[ 1 ] != ajaxLocParts[ 1 ] || parts[ 2 ] != ajaxLocParts[ 2 ] || ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) != ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ) )
In version 1.8.2 we have this:
crossDomain = parts && ( parts.join(":") + ( parts[ 3 ] ? "" : parts[ 1 ] === "http:" ? 80 : 443 ) ) !==
( ajaxLocParts.join(":") + ( ajaxLocParts[ 3 ] ? "" : ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) );
Notice how in 1.8.2 it also requires the [0] element of the array to be the same, this would not be the case for " http://www.slashdot.org" and " http://www.slashdot.org:80" for example.
A solution with minimal change would be this:
crossDomain = parts && ( parts.slice(1).join(":") + ( parts[ 3 ] ? "" : parts[ 1 ] === "http:" ? 80 : 443 ) ) !==
( ajaxLocParts.slice(1).join(":") + ( ajaxLocParts[ 3 ] ? "" : ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) );
Change History
comment:2 in reply to: ↑ 1 Changed 8 months ago by benjamin.haentjens@…
Replying to jaubourg:
I though this was unit tested. Could you provide a jsFiddle demonstrating the issue?
If it's verified, then it's a case of size-optimization gone wrong.
A fiddle: http://jsfiddle.net/pqpT2/3/
comment:3 in reply to: ↑ 1 Changed 8 months ago by benjamin.haentjens@…
Replying to jaubourg:
I though this was unit tested. If it's verified, then it's a case of size-optimization gone wrong.
I've added a fiddle unit test to the default set to demonstrate the problem in this fiddle: http://jsfiddle.net/gcRn7/
comment:4 Changed 8 months ago by jaubourg
Woah, fantastic benjamin! Thanks so much for this. I owe you a beer now!
comment:5 Changed 8 months ago by gibson042
Wow, I also thought it was tested, but benjamin is exactly right. Facepalm on my part for breaking it and for incomplete coverage.
comment:6 Changed 8 months ago by gibson042
- Owner set to gibson042
- Priority changed from undecided to high
- Status changed from new to assigned
- Component changed from unfiled to ajax
- Milestone changed from None to 1.8.3
comment:7 Changed 8 months ago by dmethvin
- Status changed from assigned to closed
- Resolution set to fixed
Fix #12635: restore 1.8.1 ajax crossDomain logic. Close gh-944.
Changeset: da3ff3afe4d8421ae4ad04d6653f04ed6d7768e3
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

I though this was unit tested. Could you provide a jsFiddle demonstrating the issue?
If it's verified, then it's a case of size-optimization gone wrong.