FIX: path whitelist for embedded comments didn't work with non-ASCII chars

This commit is contained in:
Gerhard Schlager
2017-12-12 17:56:28 +01:00
parent e30851e45a
commit a7c1b0c81f
2 changed files with 24 additions and 3 deletions

View File

@ -103,6 +103,22 @@ describe EmbeddableHost do
expect(EmbeddableHost.url_allowed?('http://eviltrout.com/rick/smith')).to eq(true)
expect(EmbeddableHost.url_allowed?('http://eviltrout.com/morty/sanchez')).to eq(true)
end
it "works with non-english paths" do
Fabricate(:embeddable_host, path_whitelist: '/انگلیسی/.*')
Fabricate(:embeddable_host, path_whitelist: '/definição/.*')
expect(EmbeddableHost.url_allowed?('http://eviltrout.com/انگلیسی/foo')).to eq(true)
expect(EmbeddableHost.url_allowed?('http://eviltrout.com/definição/foo')).to eq(true)
expect(EmbeddableHost.url_allowed?('http://eviltrout.com/bar/foo')).to eq(false)
end
it "works with URL encoded paths" do
Fabricate(:embeddable_host, path_whitelist: '/definição/.*')
Fabricate(:embeddable_host, path_whitelist: '/ingl%C3%A9s/.*')
expect(EmbeddableHost.url_allowed?('http://eviltrout.com/defini%C3%A7%C3%A3o/foo')).to eq(true)
expect(EmbeddableHost.url_allowed?('http://eviltrout.com/inglés/foo')).to eq(true)
end
end
end