Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rack: return generic error instead of leaking exception msg #99

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/falcon/adapters/rack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,11 @@ def call(request)
rescue => exception
@logger.error(self) {exception}

return failure_response(exception)
return failure_response
end

def failure_response(exception)
Protocol::HTTP::Response.for_exception(exception)
def failure_response
Protocol::HTTP::Response[500, {'content-type' => 'text/plain'}, ['Internal Server Error']]
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions spec/falcon/server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@
raise RuntimeError, "Middleware is broken"
end
end
it "results in a 500 error if middleware raises an exception" do

it "results in a 500 error (without exposing the exception msg) if middleware raises" do
response = client.get("/", {})

expect(response).to_not be_success
expect(response.status).to be == 500
expect(response.read).to be =~ /RuntimeError: Middleware is broken/
end
expect(response.read).to eq "Internal Server Error"
end
end
end