From a6846beb2f74aa38215b09a6a6dc18b912446bba Mon Sep 17 00:00:00 2001 From: Richard Loxley Date: Wed, 27 Jul 2011 16:30:28 +0100 Subject: Fixes Ticket #3709 "Embed plugin: uploading a file in Firefox tries to save a JSON file in the user's browser" --- engine/lib/actions.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'engine/lib/actions.php') diff --git a/engine/lib/actions.php b/engine/lib/actions.php index 4ccffd267..99e22e104 100644 --- a/engine/lib/actions.php +++ b/engine/lib/actions.php @@ -446,7 +446,17 @@ function ajax_forward_hook($hook, $type, $reason, $params) { $params['status'] = -1; } - header("Content-type: application/json"); + // Check the requester can accept JSON responses, if not fall back to + // returning JSON in a plain-text response. Some libraries request + // JSON in an invisible iframe which they then read from the iframe, + // however some browsers will not accept the JSON MIME type. + if (stripos($_SERVER['HTTP_ACCEPT'], 'application/json') === FALSE) { + header("Content-type: text/plain"); + } + else { + header("Content-type: application/json"); + } + echo json_encode($params); exit; } -- cgit v1.2.3