mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
FIX: do not log if an invalid mime type is passed to app
Previously our custom exception handler was unable to handle situations where an invalid mime type was sent, resulting in a warning log This ensures we pretend a request is HTML for the purpose of rendering the error page if an invalid mime type from a scanner is shipped to the app
This commit is contained in:
parent
09579bffbe
commit
423ad5f0a4
2 changed files with 44 additions and 1 deletions
|
@ -29,7 +29,15 @@ module Middleware
|
|||
begin
|
||||
fake_controller = ApplicationController.new
|
||||
fake_controller.response = response
|
||||
fake_controller.request = ActionDispatch::Request.new(env)
|
||||
fake_controller.request = request = ActionDispatch::Request.new(env)
|
||||
|
||||
begin
|
||||
request.format
|
||||
rescue Mime::Type::InvalidMimeType
|
||||
# got to do something here, we can not ship invalid format
|
||||
# to the exception handler cause it will explode
|
||||
request.format = "html"
|
||||
end
|
||||
|
||||
if ApplicationController.rescue_with_handler(exception, object: fake_controller)
|
||||
body = response.body
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue