diff options
author | Bharat Mediratta <bharat@menalto.com> | 2013-02-27 09:14:01 -0800 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2013-02-27 09:14:01 -0800 |
commit | 5bf05002717fd68828d1c6c383e53cc4c41b856a (patch) | |
tree | 69ef5ecbf8eb50260fa506ee924edb205259fcad | |
parent | 857cf537b0e04eb60da3d2d2778220308b2b5c3c (diff) | |
parent | ea4622f72635900d8ca33f2ff48848d6a35e9894 (diff) |
Merge pull request #170 from shadlaws/fix_2022
#2022 - Fix handling of watermark dialog errors.
-rw-r--r-- | lib/gallery.dialog.js | 7 | ||||
-rw-r--r-- | modules/watermark/controllers/admin_watermarks.php | 18 |
2 files changed, 7 insertions, 18 deletions
diff --git a/lib/gallery.dialog.js b/lib/gallery.dialog.js index e9f4aa03..8fe85165 100644 --- a/lib/gallery.dialog.js +++ b/lib/gallery.dialog.js @@ -137,13 +137,6 @@ }, success: function(data) { if (data.html) { - if (data.result == "error") { - // This is an odd case that arises from the watermarks module. This is because we - // have a fake xhr, and we rawurlencode the results because the JS code that uploads - // the file buffers it in an iframe which entitizes the HTML and makes it difficult - // for the JS to process. See ticket #797. - data.html = unescape(data.html); - } $("#g-dialog").html(data.html); $("#g-dialog").dialog("option", "position", "center"); $("#g-dialog form :submit").removeClass("ui-state-disabled") diff --git a/modules/watermark/controllers/admin_watermarks.php b/modules/watermark/controllers/admin_watermarks.php index 222279e8..bbefcf01 100644 --- a/modules/watermark/controllers/admin_watermarks.php +++ b/modules/watermark/controllers/admin_watermarks.php @@ -55,6 +55,8 @@ class Admin_Watermarks_Controller extends Admin_Controller { } else { json::reply(array("result" => "error", "html" => (string)$form)); } + // Override the application/json mime type for iframe compatibility. See ticket #2022. + header("Content-Type: text/plain; charset=" . Kohana::CHARSET); } public function form_delete() { @@ -83,6 +85,8 @@ class Admin_Watermarks_Controller extends Admin_Controller { } else { json::reply(array("result" => "error", "html" => (string)$form)); } + // Override the application/json mime type for iframe compatibility. See ticket #2022. + header("Content-Type: text/plain; charset=" . Kohana::CHARSET); } public function form_add() { @@ -126,18 +130,10 @@ class Admin_Watermarks_Controller extends Admin_Controller { log::success("watermark", t("Watermark saved")); json::reply(array("result" => "success", "location" => url::site("admin/watermarks"))); } else { - // rawurlencode the results because the JS code that uploads the file buffers it in an - // iframe which entitizes the HTML and makes it difficult for the JS to process. If we url - // encode it now, it passes through cleanly. See ticket #797. - json::reply(array("result" => "error", "html" => rawurlencode((string)$form))); + json::reply(array("result" => "error", "html" => (string)$form)); } - - // Override the application/json mime type. The dialog based HTML uploader uses an iframe to - // buffer the reply, and on some browsers (Firefox 3.6) it does not know what to do with the - // JSON that it gets back so it puts up a dialog asking the user what to do with it. So force - // the encoding type back to HTML for the iframe. - // See: http://jquery.malsup.com/form/#file-upload - header("Content-Type: text/html; charset=" . Kohana::CHARSET); + // Override the application/json mime type for iframe compatibility. See ticket #2022. + header("Content-Type: text/plain; charset=" . Kohana::CHARSET); } private function _update_graphics_rules() { |