mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 02:40:53 -06:00
FIX: handle invalid tags
This commit is contained in:
parent
b74c108c09
commit
9532d9a555
@ -277,10 +277,14 @@ class TagsController < ::ApplicationController
|
|||||||
def construct_url_with(action, opts)
|
def construct_url_with(action, opts)
|
||||||
method = url_method(opts)
|
method = url_method(opts)
|
||||||
|
|
||||||
url = if action == :prev
|
begin
|
||||||
public_send(method, opts.merge(prev_page_params(opts)))
|
url = if action == :prev
|
||||||
else # :next
|
public_send(method, opts.merge(prev_page_params(opts)))
|
||||||
public_send(method, opts.merge(next_page_params(opts)))
|
else # :next
|
||||||
|
public_send(method, opts.merge(next_page_params(opts)))
|
||||||
|
end
|
||||||
|
rescue
|
||||||
|
raise Discourse::NotFound
|
||||||
end
|
end
|
||||||
url.sub('.json?', '?')
|
url.sub('.json?', '?')
|
||||||
end
|
end
|
||||||
|
@ -50,6 +50,22 @@ describe TagsController do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#show' do
|
||||||
|
before do
|
||||||
|
Fabricate(:tag, name: 'test')
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should return the right response" do
|
||||||
|
get "/tags/test"
|
||||||
|
expect(response).to be_success
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should handle invalid tags" do
|
||||||
|
get "/tags/%2ftest%2f"
|
||||||
|
expect(response.status).to eq(404)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe '#check_hashtag' do
|
describe '#check_hashtag' do
|
||||||
let(:tag) { Fabricate(:tag, name: 'test') }
|
let(:tag) { Fabricate(:tag, name: 'test') }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user