FIX: unicode group names encoded for url (#8302)

This commit is contained in:
Mark VanLandingham 2019-11-06 14:25:45 -06:00 committed by GitHub
parent 6c9af6d81e
commit bf778d66b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 9 deletions

View File

@ -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?', '?')

View File

@ -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