Bug Tracker

Modify

Ticket #12635 (closed bug: fixed)

Opened 19 months ago

Last modified 19 months ago

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:1 follow-ups: ↓ 2 ↓ 3 Changed 19 months ago by jaubourg

  • Cc gibson042 added

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.

comment:2 in reply to: ↑ 1 Changed 19 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 19 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 19 months ago by jaubourg

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

comment:5 Changed 19 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 19 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 19 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.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.