]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes Ticket #3709 "Embed plugin: uploading a file in Firefox tries to save a JSON...
authorRichard Loxley <richard.loxley@surevine.com>
Wed, 27 Jul 2011 15:30:28 +0000 (16:30 +0100)
committerRichard Loxley <richard.loxley@surevine.com>
Wed, 27 Jul 2011 15:30:28 +0000 (16:30 +0100)
engine/lib/actions.php

index 4ccffd26704465ce19fa63caa1b59bbac3a7c78f..99e22e10407e3fcc116205e40aeecf8615ee549e 100644 (file)
@@ -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;
        }