Project

General

Profile

« Previous | Next » 

Revision 44dbdbc3

Added by Tom Caspy over 9 years ago

fixes #6774 - in case of parsing of non json or broken json, return 400

View differences:

lib/middleware/catch_json_parse_errors.rb
def call(env)
begin
@app.call(env)
rescue MultiJson::LoadError => error
if env['HTTP_ACCEPT'] =~ /application\/json/
rescue MultiJson::LoadError, MultiJson::ParseError => error
if env['HTTP_ACCEPT'] =~ /application\/json/ || env['CONTENT_TYPE'] =~ /application\/json/
error_output = "There was a problem in the JSON you submitted: #{error}"
Rails.logger.debug(error_output)
return [

Also available in: Unified diff