Commit f09ca0b8 authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch '218230-bugfix-save-wiki-page-modifications-with-certain-characters' into 'master'

Allow wiki pages with +<> characters in title to be saved

See merge request gitlab-org/gitlab!33803
parents 561c76d9 c5e06350
......@@ -271,7 +271,10 @@ class WikiPage
def title_changed?
if persisted?
old_title, old_dir = wiki.page_title_and_dir(self.class.unhyphenize(page.url_path))
# A page's `title` will be returned from Gollum/Gitaly with any +<>
# characters changed to -, whereas the `path` preserves these characters.
path_without_extension = Pathname(page.path).sub_ext('').to_s
old_title, old_dir = wiki.page_title_and_dir(self.class.unhyphenize(path_without_extension))
new_title, new_dir = wiki.page_title_and_dir(self.class.unhyphenize(title))
new_title != old_title || (title.include?('/') && new_dir != old_dir)
......
---
title: Allow wiki pages with +<> characters in their title to be saved
merge_request: 33803
author:
type: fixed
......@@ -651,6 +651,7 @@ describe WikiPage do
let(:untitled_page) { described_class.new(wiki) }
let(:directory_page) { create(:wiki_page, title: 'parent directory/child page') }
let(:page_with_special_characters) { create(:wiki_page, title: 'test+page') }
where(:page, :title, :changed) do
:untitled_page | nil | false
......@@ -658,6 +659,8 @@ describe WikiPage do
:new_page | nil | true
:new_page | 'test page' | true
:new_page | 'test-page' | true
:new_page | 'test+page' | true
:new_page | 'new title' | true
:existing_page | nil | false
......@@ -665,6 +668,7 @@ describe WikiPage do
:existing_page | 'test-page' | false
:existing_page | '/test page' | false
:existing_page | '/test-page' | false
:existing_page | 'test+page' | true
:existing_page | ' test page ' | true
:existing_page | 'new title' | true
:existing_page | 'new-title' | true
......@@ -681,6 +685,11 @@ describe WikiPage do
:directory_page | 'parent-directory / child-page' | true
:directory_page | 'other directory/child page' | true
:directory_page | 'other-directory/child page' | true
:page_with_special_characters | nil | false
:page_with_special_characters | 'test+page' | false
:page_with_special_characters | 'test-page' | true
:page_with_special_characters | 'test page' | true
end
with_them 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