Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kazuhiko Shiozaki
gitlab-ce
Commits
aa36a196
Commit
aa36a196
authored
May 26, 2015
by
Jeroen van Baarsen
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #9319 from jvanbaarsen/validate-wiki-page-creation
Validate wiki page creation
parents
5c2acc51
b16aad9d
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
5 deletions
+31
-5
CHANGELOG
CHANGELOG
+1
-0
app/assets/javascripts/wikis.js.coffee
app/assets/javascripts/wikis.js.coffee
+13
-5
app/views/projects/wikis/_new.html.haml
app/views/projects/wikis/_new.html.haml
+2
-0
features/project/wiki.feature
features/project/wiki.feature
+5
-0
features/steps/project/wiki.rb
features/steps/project/wiki.rb
+10
-0
No files found.
CHANGELOG
View file @
aa36a196
...
...
@@ -13,6 +13,7 @@ v 7.12.0 (unreleased)
- Fix resolving of relative links to repository files in AsciiDoc documents. (Jakub Jirutka)
- Use the user list from the target project in a merge request (Stan Hu)
- Default extention for wiki pages is now .md instead of .markdown (Jeroen van Baarsen)
- Add validation to wiki page creation (only [a-zA-Z0-9/_-] are allowed) (Jeroen van Baarsen)
v 7.11.2
- no changes
...
...
app/assets/javascripts/wikis.js.coffee
View file @
aa36a196
class
@
Wikis
constructor
:
->
$
(
'.build-new-wiki'
).
bind
"click"
,
->
$
(
'.build-new-wiki'
).
bind
"click"
,
(
e
)
->
$
(
'[data-error~=slug]'
).
addClass
(
"hidden"
)
$
(
'p.hint'
).
show
()
field
=
$
(
'#new_wiki_path'
)
valid_slug_pattern
=
/^[\w\/-]+$/
slug
=
field
.
val
()
if
slug
.
match
valid_slug_pattern
path
=
field
.
attr
(
'data-wikis-path'
)
if
(
slug
.
length
>
0
)
location
.
href
=
path
+
"/"
+
slug
else
e
.
preventDefault
()
$
(
'p.hint'
).
hide
()
$
(
'[data-error~=slug]'
).
removeClass
(
"hidden"
)
app/views/projects/wikis/_new.html.haml
View file @
aa36a196
...
...
@@ -8,6 +8,8 @@
=
label_tag
:new_wiki_path
do
%span
Page slug
=
text_field_tag
:new_wiki_path
,
nil
,
placeholder:
'how-to-setup'
,
class:
'form-control'
,
required:
true
,
:'data-wikis-path'
=>
namespace_project_wikis_path
(
@project
.
namespace
,
@project
)
%p
.hidden.text-danger
{
data:
{
error:
"slug"
}}
The page slug is invalid. Please don't use characters other then: a-z 0-9 _ - and /
%p
.hint
Please don't use spaces.
.modal-footer
...
...
features/project/wiki.feature
View file @
aa36a196
...
...
@@ -69,6 +69,11 @@ Feature: Project Wiki
And
I click on the
"Pages"
button
Then
I should see non-escaped link in the pages list
@javascript
@focus
Scenario
:
Creating an invalid new page
Given
I create a New page with an invalid name
Then
I should see an error message
@javascript
Scenario
:
Edit Wiki page that has a path
Given
I create a New page with paths
...
...
features/steps/project/wiki.rb
View file @
aa36a196
...
...
@@ -133,6 +133,16 @@ class Spinach::Features::ProjectWiki < Spinach::FeatureSteps
current_path
.
should
include
'one/two/three'
end
step
'I create a New page with an invalid name'
do
click_on
'New Page'
fill_in
'Page slug'
,
with:
'invalid name'
click_on
'Build'
end
step
'I should see an error message'
do
expect
(
page
).
to
have_content
"The page slug is invalid"
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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment