In AJAX response Content-Type: Detected Wrongly #2584

Closed
indvinoth opened this Issue Sep 9, 2015 · 6 comments

Comments

Projects
None yet
6 participants
@indvinoth

When a AJAX call is made to download an Excel file, the server responds with an Excel file and server sets the content type as below
Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
When jQuery reads the response it detects the content type as xml since in the content type contains the word 'xml' in openxmlformats. So jquery tries to parse the binary file as xml and triggers error

The content type is wrongly detected in the following function
function ajaxHandleResponses( s, jqXHR, responses )

jQuery Version used: 1.11.3

@dmethvin

This comment has been minimized.

Show comment
Hide comment
@dmethvin

dmethvin Sep 9, 2015

Member

I agree that's a pretty sloppy check. At this point I am concerned to think what will happen if we make the check more strict. The best solution for your case is to be explicit about the dataType and not let us use the infamous and misnamed "intelligent guess" algorithm, which in this case is not so smart.

As for whether we can or will change the intelligent guess algorithm, that's a discussion we need to have.

Member

dmethvin commented Sep 9, 2015

I agree that's a pretty sloppy check. At this point I am concerned to think what will happen if we make the check more strict. The best solution for your case is to be explicit about the dataType and not let us use the infamous and misnamed "intelligent guess" algorithm, which in this case is not so smart.

As for whether we can or will change the intelligent guess algorithm, that's a discussion we need to have.

@mgol mgol added the Needs review label Oct 7, 2015

@mgol

This comment has been minimized.

Show comment
Hide comment
@mgol

mgol Oct 7, 2015

Member

I added the "Needs review" label to discuss it at the meeting.

This sounds like a bug to me, IMO we should fix it for 3.0.0.

Member

mgol commented Oct 7, 2015

I added the "Needs review" label to discuss it at the meeting.

This sounds like a bug to me, IMO we should fix it for 3.0.0.

@markelog markelog added the Ajax label Oct 8, 2015

@markelog

This comment has been minimized.

Show comment
Hide comment
Member

markelog commented Oct 8, 2015

/cc @jaubourg

@jaubourg

This comment has been minimized.

Show comment
Hide comment
@jaubourg

jaubourg Oct 9, 2015

Member

Out the top of my hat, I'd say replacing /xml/ with /\bxml\b/ should do the trick.

Member

jaubourg commented Oct 9, 2015

Out the top of my hat, I'd say replacing /xml/ with /\bxml\b/ should do the trick.

@markelog

This comment has been minimized.

Show comment
Hide comment
@markelog

markelog Oct 9, 2015

Member

aam, what about text/xml? we should do it for the other types as well then

Member

markelog commented Oct 9, 2015

aam, what about text/xml? we should do it for the other types as well then

@jaubourg

This comment has been minimized.

Show comment
Hide comment
@jaubourg

jaubourg Oct 9, 2015

Member

aam, what about text/xml? we should do it for the other types as well then

You wouldn't catch stuff like application/rss+xml.

Anyway, we just need to make sure we don't catch xml as part of a word which /\bxml\b/ ensures. All dataType detection regexps should follow the same pattern.

Member

jaubourg commented Oct 9, 2015

aam, what about text/xml? we should do it for the other types as well then

You wouldn't catch stuff like application/rss+xml.

Anyway, we just need to make sure we don't catch xml as part of a word which /\bxml\b/ ensures. All dataType detection regexps should follow the same pattern.

@timmywil timmywil added this to the 3.0.0 milestone Oct 12, 2015

@timmywil timmywil removed the Needs review label Oct 12, 2015

markelog added a commit to markelog/jquery that referenced this issue Oct 12, 2015

markelog added a commit to markelog/jquery that referenced this issue Oct 12, 2015

markelog added a commit that referenced this issue Oct 12, 2015

@markelog markelog closed this in 239169b Oct 12, 2015

@dmethvin dmethvin modified the milestones: 1.12/2.2, 3.0.0 Jan 8, 2016

@cssmagic cssmagic referenced this issue in cssmagic/ChangeLog May 18, 2016

Open

jQuery #5

@jquery jquery locked as resolved and limited conversation to collaborators Jun 19, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.