Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-wiki
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
django-wiki
Commits
16063dbe
Commit
16063dbe
authored
Sep 09, 2014
by
benjaoming
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #300 from pknowles/master
Added validation for slugs conflicting with 3rd party URLs
parents
20748ad4
20041bd7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
0 deletions
+14
-0
wiki/conf/settings.py
+4
-0
wiki/forms.py
+10
-0
No files found.
wiki/conf/settings.py
View file @
16063dbe
...
...
@@ -26,6 +26,10 @@ MARKDOWN_KWARGS.update(getattr( django_settings, 'WIKI_MARKDOWN_KWARGS', {} ))
# and all their content.
LOST_AND_FOUND_SLUG
=
getattr
(
django_settings
,
'WIKI_LOST_AND_FOUND_SLUG'
,
'lost-and-found'
)
# When True, this blocks new slugs that resolve to non-wiki views, stopping
# users creating articles that conflict with overlapping URLs from other apps.
CHECK_SLUG_URL_AVAILABLE
=
getattr
(
django_settings
,
'WIKI_CHECK_SLUG_URL_AVAILABLE'
,
True
)
# Do we want to log IPs?
LOG_IPS_ANONYMOUS
=
getattr
(
django_settings
,
'WIKI_LOG_IPS_ANONYMOUS'
,
True
)
LOG_IPS_USERS
=
getattr
(
django_settings
,
'WIKI_LOG_IPS_USERS'
,
False
)
...
...
wiki/forms.py
View file @
16063dbe
...
...
@@ -16,6 +16,7 @@ except ImportError:
def
force_unicode
(
x
):
return
(
x
)
from
django.utils.html
import
escape
,
conditional_escape
from
django.core.urlresolvers
import
resolve
,
Resolver404
from
itertools
import
chain
...
...
@@ -271,6 +272,15 @@ class CreateForm(forms.Form, SpamProtectionMixin):
else
:
raise
forms
.
ValidationError
(
_
(
'A slug named "
%
s" already exists.'
)
%
already_urlpath
.
slug
)
if
settings
.
CHECK_SLUG_URL_AVAILABLE
:
try
:
# Fail validation if URL resolves to non-wiki app
match
=
resolve
(
self
.
urlpath_parent
.
path
+
'/'
+
slug
+
'/'
)
if
match
.
app_name
!=
'wiki'
:
raise
forms
.
ValidationError
(
_
(
'This slug conflicts with an existing URL.'
))
except
Resolver404
:
pass
return
slug
def
clean
(
self
):
...
...
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