Skip to content

Commit

Permalink
Merge pull request #170 from shadlaws/fix_2022
Browse files Browse the repository at this point in the history
#2022 - Fix handling of watermark dialog errors.
  • Loading branch information
bharat committed Feb 27, 2013
2 parents 857cf53 + ea4622f commit 5bf0500
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
7 changes: 0 additions & 7 deletions lib/gallery.dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
18 changes: 7 additions & 11 deletions modules/watermark/controllers/admin_watermarks.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public function edit() {
} 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() {
Expand Down Expand Up @@ -83,6 +85,8 @@ public function delete() {
} 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() {
Expand Down Expand Up @@ -126,18 +130,10 @@ public function add() {
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() {
Expand Down

0 comments on commit 5bf0500

Please sign in to comment.