Skip to main content

Bug Tracker

Side navigation

#12635 closed bug (fixed)

Opened October 01, 2012 11:50AM UTC

Closed October 04, 2012 01:49AM UTC

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@ordina.be Owned by: gibson042
Priority: high Milestone: 1.8.3
Component: ajax Version: 1.8.2
Keywords: Cc: gibson042
Blocked by: Blocking:
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 ) );
Attachments (0)
Change History (7)

Changed October 01, 2012 12:33PM UTC by jaubourg comment:1

cc: → gibson042

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.

Changed October 01, 2012 12:48PM UTC by benjamin.haentjens@ordina.be comment:2

Replying to [comment:1 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/

Changed October 01, 2012 06:12PM UTC by benjamin.haentjens@ordina.be comment:3

Replying to [comment:1 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/

Changed October 01, 2012 06:16PM UTC by jaubourg comment:4

Woah, fantastic benjamin! Thanks so much for this. I owe you a beer now!

Changed October 03, 2012 02:59AM UTC by gibson042 comment:5

Wow, I also thought it was tested, but benjamin is exactly right. Facepalm on my part for breaking it and for incomplete coverage.

Changed October 03, 2012 12:27PM UTC by gibson042 comment:6

component: unfiledajax
milestone: None1.8.3
owner: → gibson042
priority: undecidedhigh
status: newassigned

Changed October 04, 2012 01:49AM UTC by dmethvin comment:7

resolution: → fixed
status: assignedclosed

Fix #12635: restore 1.8.1 ajax crossDomain logic. Close gh-944.

Changeset: da3ff3afe4d8421ae4ad04d6653f04ed6d7768e3