Commit ad699c72 authored by Jérome Perrin's avatar Jérome Perrin

web_renderjs_ui: fix detection of Base_redirect redirections

The check was made on the blob response type, which is set from the
Content-Type header returned by the server, but Safari has a different
interpretation of the charset parameter from the mime type, with a
content type set to application/json;charset=utf-8 like Base_redirect
does today, safari creates a blob with type application/json;charset=utf-8
and this was not detected as redirection and the json returned by
Base_redirect was downloaded. Fix this by checking only the essence
of the type.

This also revealed a potential problem when actually downloading json
files, in that case we also check that we have the X-Location header,
that is supposed to be set by Base_redirect before interpreting the json
and when it's not present we force download.
parent 9f3d6a99
......@@ -384,7 +384,11 @@ and handling data send&receive.
.push(function (attachment) {
var response;
if (attachment.target.response.type === "application/json") {
if (
attachment.target.response.type.split(";")[0].trim() ===
"application/json" &&
attachment.target.getResponseHeader("X-Location")
) {
// successful form save returns simple redirect and an answer as JSON
return new RSVP.Queue()
.push(function () {
......@@ -466,14 +470,14 @@ and handling data send&receive.
})
.push(function () {
// Make sure to return nothing (previous render can return
// something) so the successfull handler does not receive
// something) so the successful handler does not receive
// anything which it could consider as redirect jio key.
return result;
});
});
}
// response status > 200 (e.g. 202 "Accepted" or 204 "No Content")
// means a sucessful execution of the action but does not carry any data
// means a successful execution of the action but does not carry any data
// XMLHttpRequest automatically inserts Content-Type="text/xml" thus
// we cannot test based on that
if (attachment.target.response.size === 0 &&
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment