diff options
author | Richard Loxley <richard.loxley@surevine.com> | 2011-07-27 16:30:28 +0100 |
---|---|---|
committer | Richard Loxley <richard.loxley@surevine.com> | 2011-07-27 16:30:28 +0100 |
commit | a6846beb2f74aa38215b09a6a6dc18b912446bba (patch) | |
tree | 9b973ec28fe90952669ade0eb2bb21edc3aa2e4e /engine/lib | |
parent | c5ab33dfbd4379cd5971a583fcde65246b47a013 (diff) | |
download | elgg-a6846beb2f74aa38215b09a6a6dc18b912446bba.tar.gz elgg-a6846beb2f74aa38215b09a6a6dc18b912446bba.tar.bz2 |
Fixes Ticket #3709 "Embed plugin: uploading a file in Firefox tries to save a JSON file in the user's browser"
Diffstat (limited to 'engine/lib')
-rw-r--r-- | engine/lib/actions.php | 12 |
1 files changed, 11 insertions, 1 deletions
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; } |