When returning a json error, don't use a raw unescaped string (#15879)
The 400 and 403 error pages show json parsing errors in most browsers,
since "Error: Bad Request" is not a valid json body ('"Error: Bad
Request"' would be, or the object with key error and value of the
string which I've selected is _also_ valid).
Do we have frontend code that's looking for this body before it parses
for some reason, or was this just a mistaken copying from the api
controller in the initial PRs (#2293 for not_authorized, and #6248 for
the bad_request method, which may have just replicated the decision
for not_authorized)?
This commit is contained in:
parent
0b8c09851c
commit
4d40ea18a2
1 changed files with 2 additions and 2 deletions
|
|
@ -74,12 +74,12 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
def not_authorized
|
||||
render json: "Error: not authorized", status: :unauthorized
|
||||
render json: {error: "Error: not authorized"}, status: :unauthorized
|
||||
raise NotAuthorizedError, "Unauthorized"
|
||||
end
|
||||
|
||||
def bad_request
|
||||
render json: "Error: Bad Request", status: :bad_request
|
||||
render json: {error: "Error: Bad Request"}, status: :bad_request
|
||||
end
|
||||
|
||||
def error_too_many_requests(exc)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue