summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-03-22 23:32:00 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-03-22 23:32:00 +0000
commit1d85e5fffff66e5b074480d91b414968955b1ee5 (patch)
treeec834d42292d0d53a6ff5a2cd298454053d0d6d5 /app
parent751053664333f1f4d098daa5b676a1685339a779 (diff)
parent59d5c779758a696233d2f2adcf145c0a93a8fb2f (diff)
downloadgitlab-ce-1d85e5fffff66e5b074480d91b414968955b1ee5.tar.gz
Merge branch 'fix-dots-in-wiki-title' into 'master'
Fix dots in Wiki slug causing errors ### What does this MR do? When a user enters in dots into the Wiki slug, an error occurs: ``` NoMethodError (undefined method `escaped_url_path' for nil:NilClass): app/models/wiki_page.rb:172:in `set_attributes' app/models/wiki_page.rb:191:in `save' app/models/wiki_page.rb:155:in `update' app/controllers/projects/wikis_controller.rb:49:in `update' ``` This MR fixes this problem. ### Are there points in the code the reviewer needs to double check? See the problem below. ### Why was this MR needed? The issue is that the `save` method gets called differently: ```ruby def create(attr = {}) .... save :create_page, title, content, format, message ``` or ```ruby def update(new_content = "", format = :markdown, message = nil) ... save :update_page, @page, content, format, message ``` In the create case, title is the slug entered in by the user (e.g. `path/how-to-write-wiki-pages`). In the update case, originally `@page.page` included the format extension (e.g.`path/how-to-write-wiki-pages.Markdown`). The method `page_title_and_dir` was trying to handle both cases and not doing the right thing. For example, calling `page_title_and_dir('test-1.2.3')` would result in: ``` path_title = test-1.2 path_dir = 3 ``` ### What are the relevant issue numbers / [Feature requests](http://feedback.gitlab.com/)? Issues #1263, #431 This replaces !156 See merge request !419
Diffstat (limited to 'app')
-rw-r--r--app/models/project_wiki.rb2
-rw-r--r--app/models/wiki_page.rb3
2 files changed, 3 insertions, 2 deletions
diff --git a/app/models/project_wiki.rb b/app/models/project_wiki.rb
index 55438bee245..772c868d9cd 100644
--- a/app/models/project_wiki.rb
+++ b/app/models/project_wiki.rb
@@ -104,7 +104,7 @@ class ProjectWiki
def page_title_and_dir(title)
title_array = title.split("/")
title = title_array.pop
- [title.gsub(/\.[^.]*$/, ""), title_array.join("/")]
+ [title, title_array.join("/")]
end
def search_files(query)
diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb
index 32981a0e664..e9413c34bae 100644
--- a/app/models/wiki_page.rb
+++ b/app/models/wiki_page.rb
@@ -179,7 +179,8 @@ class WikiPage
if valid? && project_wiki.send(method, *args)
page_details = if method == :update_page
- @page.path
+ # Use url_path instead of path to omit format extension
+ @page.url_path
else
title
end