Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In AJAX response Content-Type: Detected Wrongly #2584

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

In AJAX response Content-Type: Detected Wrongly #2584

indvinoth opened this issue Sep 9, 2015 · 6 comments
Assignees
Labels
Milestone

Comments

@indvinoth
Copy link

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
Copy link
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
Copy link
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
Copy link
Member

markelog commented Oct 8, 2015

/cc @jaubourg

@jaubourg
Copy link
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
Copy link
Member

markelog commented Oct 9, 2015

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

@jaubourg
Copy link
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
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
@dmethvin dmethvin modified the milestones: 1.12/2.2, 3.0.0 Jan 8, 2016
@lock lock bot 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.
Labels
Development

No branches or pull requests

6 participants