FIX: Crazy large ids should not raise exceptions

This commit is contained in:
Robin Ward
2016-03-23 12:13:29 -04:00
parent bba0393c87
commit 4180e207c3
2 changed files with 15 additions and 1 deletions

View File

@ -100,7 +100,16 @@ class ApplicationController < ActionController::Base
class PluginDisabled < StandardError; end
rescue_from Discourse::NotFound, PluginDisabled do
# Handles requests for giant IDs that throw pg exceptions
rescue_from RangeError do |e|
if e.message =~ /ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Integer/
rescue_discourse_actions(:not_found, 404)
else
raise e
end
end
rescue_from Discourse::NotFound, PluginDisabled do
rescue_discourse_actions(:not_found, 404)
end