Commit be26c4e7 authored by Ahmad Sherif's avatar Ahmad Sherif

Encode GitalyClient::WikiPage attributes to UTF-8

parent 19277271
...@@ -4,6 +4,7 @@ module Gitlab ...@@ -4,6 +4,7 @@ module Gitlab
ATTRS = %i(title format url_path path name historical raw_data).freeze ATTRS = %i(title format url_path path name historical raw_data).freeze
include AttributesBag include AttributesBag
include Gitlab::EncodingHelper
def initialize(params) def initialize(params)
super super
...@@ -11,6 +12,10 @@ module Gitlab ...@@ -11,6 +12,10 @@ module Gitlab
# All gRPC strings in a response are frozen, so we get an unfrozen # All gRPC strings in a response are frozen, so we get an unfrozen
# version here so appending to `raw_data` doesn't blow up. # version here so appending to `raw_data` doesn't blow up.
@raw_data = @raw_data.dup @raw_data = @raw_data.dup
@title = encode_utf8(@title)
@path = encode_utf8(@path)
@name = encode_utf8(@name)
end end
def historical? def historical?
......
...@@ -127,7 +127,7 @@ describe ProjectWiki do ...@@ -127,7 +127,7 @@ describe ProjectWiki do
end end
after do after do
destroy_page(subject.pages.first.page) subject.pages.each { |page| destroy_page(page.page) }
end end
it "returns the latest version of the page if it exists" do it "returns the latest version of the page if it exists" do
...@@ -148,6 +148,17 @@ describe ProjectWiki do ...@@ -148,6 +148,17 @@ describe ProjectWiki do
page = subject.find_page("index page") page = subject.find_page("index page")
expect(page).to be_a WikiPage expect(page).to be_a WikiPage
end end
context 'pages with multibyte-character title' do
before do
create_page("autre pagé", "C'est un génial Gollum Wiki")
end
it "can find a page by slug" do
page = subject.find_page("autre pagé")
expect(page.title).to eq("autre pagé")
end
end
end end
context 'when Gitaly wiki_find_page is enabled' do context 'when Gitaly wiki_find_page is enabled' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment