mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-30 10:58:31 -05:00
FIX: Crazy large ids should not raise exceptions
This commit is contained in:
parent
bba0393c87
commit
4180e207c3
2 changed files with 15 additions and 1 deletions
|
@ -100,7 +100,16 @@ class ApplicationController < ActionController::Base
|
||||||
|
|
||||||
class PluginDisabled < StandardError; end
|
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)
|
rescue_discourse_actions(:not_found, 404)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -578,6 +578,11 @@ describe TopicsController do
|
||||||
expect(response.status).to eq(404)
|
expect(response.status).to eq(404)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'returns a 404 for an ID that is larger than postgres limits' do
|
||||||
|
xhr :get, :show, topic_id: 50142173232201640412, slug: 'topic-that-is-made-up'
|
||||||
|
expect(response.status).to eq(404)
|
||||||
|
end
|
||||||
|
|
||||||
context 'a topic with nil slug exists' do
|
context 'a topic with nil slug exists' do
|
||||||
before do
|
before do
|
||||||
@nil_slug_topic = Fabricate(:topic)
|
@nil_slug_topic = Fabricate(:topic)
|
||||||
|
|
Loading…
Reference in a new issue