mirror of
https://github.com/discourse/discourse.git
synced 2025-04-19 21:09:11 +08:00
FIX: unicode group names encoded for url (#8302)
This commit is contained in:
parent
6c9af6d81e
commit
bf778d66b5
@ -385,6 +385,9 @@ class ListController < ApplicationController
|
||||
end
|
||||
|
||||
opts = opts.dup
|
||||
if SiteSetting.unicode_usernames && opts[:group_name]
|
||||
opts[:group_name] = URI.encode(opts[:group_name])
|
||||
end
|
||||
opts.delete(:category) if page_params.include?(:category_slug_path_with_id)
|
||||
|
||||
public_send(method, opts.merge(page_params)).sub('.json?', '?')
|
||||
|
@ -195,19 +195,34 @@ RSpec.describe ListController do
|
||||
user
|
||||
end
|
||||
|
||||
let!(:topic) do
|
||||
Fabricate(:private_message_topic,
|
||||
allowed_groups: [group],
|
||||
)
|
||||
describe 'with unicode_usernames' do
|
||||
before { SiteSetting.unicode_usernames = false }
|
||||
|
||||
it 'should return the right response' do
|
||||
group.add(user)
|
||||
topic = Fabricate(:private_message_topic, allowed_groups: [group])
|
||||
get "/topics/private-messages-group/#{user.username}/#{group.name}.json"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
expect(JSON.parse(response.body)["topic_list"]["topics"].first["id"])
|
||||
.to eq(topic.id)
|
||||
end
|
||||
end
|
||||
|
||||
it 'should return the right response' do
|
||||
get "/topics/private-messages-group/#{user.username}/#{group.name}.json"
|
||||
describe 'with unicode_usernames' do
|
||||
before { SiteSetting.unicode_usernames = true }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
it 'Returns a 200 with unicode group name' do
|
||||
unicode_group = Fabricate(:group, name: '群群组')
|
||||
unicode_group.add(user)
|
||||
topic = Fabricate(:private_message_topic, allowed_groups: [unicode_group])
|
||||
get "/topics/private-messages-group/#{user.username}/#{URI.escape(unicode_group.name)}.json"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
expect(JSON.parse(response.body)["topic_list"]["topics"].first["id"])
|
||||
.to eq(topic.id)
|
||||
expect(JSON.parse(response.body)["topic_list"]["topics"].first["id"])
|
||||
.to eq(topic.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user