Commit 3143edfe authored by Stan Hu's avatar Stan Hu

Fix bug where Wiki pages that include a '/' were no longer accessible

Closes #1363
parent 7feec5fe
Please view this file on the master branch, on stable branches it's out of date.
v 7.10.0 (unreleased)
- Fix bug where Wiki pages that included a '/' were no longer accessible (Stan Hu)
- Fix bug where error messages from Dropzone would not be displayed on the issues page (Stan Hu)
- Add ability to configure Reply-To address in gitlab.yml (Stan Hu)
- Fix broken side-by-side diff view on merge request page (Stan Hu)
......
......@@ -5,6 +5,7 @@ class Projects::WikisController < Projects::ApplicationController
before_filter :authorize_write_wiki!, only: [:edit, :create, :history]
before_filter :authorize_admin_wiki!, only: :destroy
before_filter :load_project_wiki
include WikiHelper
def pages
@wiki_pages = Kaminari.paginate_array(@project_wiki.pages).page(params[:page]).per(PER_PAGE)
......@@ -45,7 +46,10 @@ def update
return render('empty') unless can?(current_user, :write_wiki, @project)
if @page.update(content, format, message)
redirect_to [@project.namespace.becomes(Namespace), @project, @page], notice: 'Wiki was successfully updated.'
redirect_to(
namespace_project_wiki_path(@project.namespace, @project, @page),
notice: 'Wiki was successfully updated.'
)
else
render 'edit'
end
......
module WikiHelper
# Rails v4.1.9+ escapes all model IDs, converting slashes into %2F. The
# only way around this is to implement our own path generators.
def namespace_project_wiki_path(namespace, project, wiki_page, *args)
slug =
case wiki_page
when Symbol
wiki_page
else
wiki_page.slug
end
namespace_project_path(namespace, project) + "/wikis/#{slug}"
end
def edit_namespace_project_wiki_path(namespace, project, wiki_page, *args)
namespace_project_wiki_path(namespace, project, wiki_page) + '/edit'
end
def history_namespace_project_wiki_path(namespace, project, wiki_page, *args)
namespace_project_wiki_path(namespace, project, wiki_page) + '/history'
end
end
......@@ -62,3 +62,27 @@ Feature: Project Wiki
And I browse to wiki page with images
And I click on image link
Then I should see the new wiki page form
@javascript
Scenario: New Wiki page that has a path
Given I create a New page with paths
And I click on the "Pages" button
Then I should see non-escaped link in the pages list
@javascript
Scenario: Edit Wiki page that has a path
Given I create a New page with paths
And I click on the "Pages" button
And I edit the Wiki page with a path
Then I should see a non-escaped path
And I should see the Editing page
And I change the content
Then I should see the updated content
@javascript
Scenario: View the page history of a Wiki page that has a path
Given I create a New page with paths
And I click on the "Pages" button
And I view the page history of a Wiki page that has a path
Then I should see a non-escaped path
And I should see the page history
......@@ -3,6 +3,7 @@ class Spinach::Features::ProjectWiki < Spinach::FeatureSteps
include SharedProject
include SharedNote
include SharedPaths
include WikiHelper
step 'I click on the Cancel button' do
within(:css, ".form-actions") do
......@@ -123,6 +124,41 @@ class Spinach::Features::ProjectWiki < Spinach::FeatureSteps
page.should have_content('Editing - image.jpg')
end
step 'I create a New page with paths' do
click_on 'New Page'
fill_in 'Page slug', with: 'one/two/three'
click_on 'Build'
fill_in "wiki_content", with: 'wiki content'
click_on "Create page"
current_path.should include 'one/two/three'
end
step 'I should see non-escaped link in the pages list' do
page.should have_xpath("//a[@href='/#{project.path_with_namespace}/wikis/one/two/three']")
end
step 'I edit the Wiki page with a path' do
click_on 'three'
click_on 'Edit'
end
step 'I should see a non-escaped path' do
current_path.should include 'one/two/three'
end
step 'I should see the Editing page' do
page.should have_content('Editing')
end
step 'I view the page history of a Wiki page that has a path' do
click_on 'three'
click_on 'Page History'
end
step 'I should see the page history' do
page.should have_content('History for')
end
def wiki
@project_wiki = ProjectWiki.new(project, current_user)
end
......
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