diff options
author | Robert Speicher <robert@gitlab.com> | 2018-02-05 15:31:39 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2018-02-05 15:31:39 +0000 |
commit | bfb32b46327576f5b5d4ff3d42198ba4601f1830 (patch) | |
tree | 4040d2f27dd8785bab5d2efcc3ff6d7d559844f5 | |
parent | 0e15a5b805e832c22c67cead8c4829e6c77cd498 (diff) | |
parent | be26c4e728a2704d79a17df0edf84689b44eebd6 (diff) | |
download | gitlab-ce-bfb32b46327576f5b5d4ff3d42198ba4601f1830.tar.gz |
Merge branch 'fix/gitaly-wiki-encoding-issues' into 'master'
Encode GitalyClient::WikiPage attributes to UTF-8
See merge request gitlab-org/gitlab-ce!16925
-rw-r--r-- | lib/gitlab/gitaly_client/wiki_page.rb | 5 | ||||
-rw-r--r-- | spec/models/project_wiki_spec.rb | 13 |
2 files changed, 17 insertions, 1 deletions
diff --git a/lib/gitlab/gitaly_client/wiki_page.rb b/lib/gitlab/gitaly_client/wiki_page.rb index 7339468e911..a02d15db5dd 100644 --- a/lib/gitlab/gitaly_client/wiki_page.rb +++ b/lib/gitlab/gitaly_client/wiki_page.rb @@ -4,6 +4,7 @@ module Gitlab ATTRS = %i(title format url_path path name historical raw_data).freeze include AttributesBag + include Gitlab::EncodingHelper def initialize(params) super @@ -11,6 +12,10 @@ module Gitlab # All gRPC strings in a response are frozen, so we get an unfrozen # version here so appending to `raw_data` doesn't blow up. @raw_data = @raw_data.dup + + @title = encode_utf8(@title) + @path = encode_utf8(@path) + @name = encode_utf8(@name) end def historical? diff --git a/spec/models/project_wiki_spec.rb b/spec/models/project_wiki_spec.rb index 929086305ba..1e7671476f1 100644 --- a/spec/models/project_wiki_spec.rb +++ b/spec/models/project_wiki_spec.rb @@ -127,7 +127,7 @@ describe ProjectWiki do end after do - destroy_page(subject.pages.first.page) + subject.pages.each { |page| destroy_page(page.page) } end it "returns the latest version of the page if it exists" do @@ -148,6 +148,17 @@ describe ProjectWiki do page = subject.find_page("index page") expect(page).to be_a WikiPage 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 context 'when Gitaly wiki_find_page is enabled' do |