From 28bd9395803b36c7b8319a1bd63283abcf87a09a Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Sun, 30 Sep 2012 16:32:22 +1300 Subject: [PATCH] FIX: Ignore charset when checking mime types in LeftAndMain ajax responses. This is partly a fix to #7574, although quite different from the work Ingo did on Content-length. The text/json mime type occasionally gets a charset suffixed to it by the webserver, which broke everything. A follow-on fix from this would be to get the PHP code to supply charsets more consistently, so that webservers don't have to make things up. Additionally, the 2nd interpretation - which treats the response as text/html - should probably only happen if the response is text/html, and throw a more helpful error otherwise. --- admin/javascript/LeftAndMain.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/admin/javascript/LeftAndMain.js b/admin/javascript/LeftAndMain.js index 190700ead..50dec931e 100644 --- a/admin/javascript/LeftAndMain.js +++ b/admin/javascript/LeftAndMain.js @@ -379,7 +379,8 @@ jQuery.noConflict(); if(title) document.title = title; var newFragments = {}, newContentEls; - if(xhr.getResponseHeader('Content-Type') == 'text/json') { + // If content type is text/json (ignoring charset and other parameters) + if(xhr.getResponseHeader('Content-Type').match(/^text\/json[ \t]*;?/i)) { newFragments = data; } else { // Fall back to replacing the content fragment if HTML is returned