Skip to content

Commit

Permalink
Fix for ticket #797
Browse files Browse the repository at this point in the history
When load a file is uploaded using a dialog box and the jquery plugin ajaxForm, the ajaxForm plugin uses an hidden iFrame element to send the multi-part
form and this is where the response goes.  The ajaxForm plugin then retrieves the document body and parses the result as a json string. If the file uploads
properly everything is fine, but if it fails Gallery3 return the input form with the the error fields highlighted as part of the json response. As this
response is returned to a hidden iframe, the browser attempts to manipulate it and all hell breaks loose. We lose the trailing brace, we start getting
escaping of form tags. When the ajaxForm plugin retrieves the iFrame body its no longer a valid json frame and the parsing fails and the user sees no
indication that it failed.
  • Loading branch information
Tim Almdal committed Jun 11, 2010
1 parent 30f4e14 commit bb35aef
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/gallery.dialog.js
Expand Up @@ -114,7 +114,8 @@
},
success: function(data) {
if (data.form) {
$("#g-dialog form").replaceWith(data.form);
var formData = unescape(data.form);
$("#g-dialog form").replaceWith(formData);
$("#g-dialog form :submit").removeClass("ui-state-disabled")
.attr("disabled", null);
self._ajaxify_dialog();
Expand Down
2 changes: 1 addition & 1 deletion modules/watermark/controllers/admin_watermarks.php
Expand Up @@ -124,7 +124,7 @@ public function add() {
array("result" => "success",
"location" => url::site("admin/watermarks")));
} else {
print json_encode(array("result" => "error", "form" => (string) $form));
print json_encode(array("result" => "error", "form" => rawurlencode((string) $form)));
}
}

Expand Down

0 comments on commit bb35aef

Please sign in to comment.