Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wiki-js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
wiki-js
Commits
5b64c951
Commit
5b64c951
authored
Apr 19, 2019
by
Nick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: block creating pages with system reserved paths
parent
e597a7df
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
6 deletions
+22
-6
config.sample.yml
config.sample.yml
+1
-1
config.yml
dev/build/config.yml
+0
-5
data.yml
server/app/data.yml
+10
-0
common.js
server/controllers/common.js
+5
-0
page.js
server/helpers/page.js
+6
-0
No files found.
config.sample.yml
View file @
5b64c951
...
...
@@ -2,7 +2,7 @@
# Wiki.js - CONFIGURATION #
#######################################################################
# Full documentation + examples:
# https://docs
.requarks.io/wiki
/install
# https://docs
-beta.requarks.io
/install
# ---------------------------------------------------------------------
# Port the server should listen to
...
...
dev/build/config.yml
View file @
5b64c951
...
...
@@ -8,10 +8,5 @@ db:
pass
:
$(DB_PASS)
db
:
$(DB_NAME)
storage
:
$(DB_FILEPATH)
redis
:
host
:
$(REDIS_HOST)
port
:
$(REDIS_PORT)
db
:
$(REDIS_DB)
password
:
$(REDIS_PASS)
trustProxy
:
$(TRUST_PROXY)
logLevel
:
info
server/app/data.yml
View file @
5b64c951
...
...
@@ -72,4 +72,14 @@ telemetry:
BUGSNAG_REMOTE
:
'
https://notify.bugsnag.com'
GA_ID
:
'
UA-9094100-7'
GA_REMOTE
:
'
https://www.google-analytics.com/batch'
reservedPaths
:
-
login
-
logout
-
register
-
verify
-
favicons
-
fonts
-
img
-
js
-
svg
# ---------------------------------
server/controllers/common.js
View file @
5b64c951
...
...
@@ -22,6 +22,11 @@ router.get('/robots.txt', (req, res, next) => {
*/
router
.
get
([
'/e'
,
'/e/*'
],
async
(
req
,
res
,
next
)
=>
{
const
pageArgs
=
pageHelper
.
parsePath
(
req
.
path
)
if
(
pageHelper
.
isReservedPath
(
pageArgs
.
path
))
{
return
next
(
new
Error
(
'Cannot create this page because it starts with a system reserved path.'
))
}
let
page
=
await
WIKI
.
models
.
pages
.
getPageFromDb
({
path
:
pageArgs
.
path
,
locale
:
pageArgs
.
locale
,
...
...
server/helpers/page.js
View file @
5b64c951
...
...
@@ -56,5 +56,11 @@ module.exports = {
default
:
return
page
.
content
}
},
/**
* Check if path is a reserved path
*/
isReservedPath
(
rawPath
)
{
return
_
.
some
(
WIKI
.
data
.
reservedPaths
,
p
=>
_
.
startsWith
(
rawPath
,
p
))
}
}
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