FIX: Handle uncaught exception (#11263)

After the search term is parsed for advanced search filters, the term may
become empty. Later, the same term will be passed to Discourse.route_for
which will raise an ArgumentError.

> URI(nil)
ArgumentError: bad argument (expected URI object or URI string)
This commit is contained in:
Dan Ungureanu
2020-11-20 11:28:14 +02:00
committed by GitHub
parent c244214fe5
commit 9b7525bb03
3 changed files with 10 additions and 8 deletions

View File

@@ -231,6 +231,11 @@ describe SearchController do
expect(SearchLog.where(term: 'wookie')).to be_blank
end
it "does not raise 500 with an empty term" do
get "/search/query.json", params: { term: "in:first", type_filter: "topic", search_for_id: true }
expect(response.status).to eq(200)
end
context 'rate limited' do
it 'rate limits anon searches per user' do
SiteSetting.rate_limit_search_anon_user = 2