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:
def create(attr = {})
....
save :create_page, title, content, format, message
or
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
Feature requests?
What are the relevant issue numbers /Issues #1263 (closed), #431 (closed)
This replaces !156 (closed)