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
084dcd69
You need to sign in or sign up before continuing.
Commit
084dcd69
authored
Oct 03, 2020
by
NGPixel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: strip directory traversal sequences from asset paths
parent
9ccd1f82
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
2 deletions
+8
-2
page.js
server/helpers/page.js
+8
-2
No files found.
server/helpers/page.js
View file @
084dcd69
...
...
@@ -5,6 +5,8 @@ const path = require('path')
const
localeSegmentRegex
=
/^
[
A-Z
]{2}(
-
[
A-Z
]{2})?
$/i
const
localeFolderRegex
=
/^
([
a-z
]{2}(?:
-
[
a-z
]{2})?\/)?(
.*
)
/i
// eslint-disable-next-line no-control-regex
const
unsafeCharsRegex
=
/
[\x
00-
\x
1f
\x
80-
\x
9f
\\
"|<>:*?
]
/
const
contentToExt
=
{
markdown
:
'md'
,
...
...
@@ -30,10 +32,14 @@ module.exports = {
// Clean Path
rawPath
=
_
.
trim
(
qs
.
unescape
(
rawPath
))
if
(
_
.
startsWith
(
rawPath
,
'/'
))
{
rawPath
=
rawPath
.
substring
(
1
)
}
rawPath
=
rawPath
.
replace
(
unsafeCharsRegex
,
''
)
if
(
rawPath
===
''
)
{
rawPath
=
'home'
}
// Extract Info
let
pathParts
=
_
.
filter
(
_
.
split
(
rawPath
,
'/'
),
p
=>
!
_
.
isEmpty
(
p
))
let
pathParts
=
_
.
filter
(
_
.
split
(
rawPath
,
'/'
),
p
=>
{
p
=
_
.
trim
(
p
)
return
!
_
.
isEmpty
(
p
)
&&
p
!==
'..'
&&
p
!==
'.'
})
if
(
pathParts
[
0
].
length
===
1
)
{
pathParts
.
shift
()
}
...
...
@@ -73,7 +79,7 @@ module.exports = {
[
'date'
,
page
.
updatedAt
],
[
'tags'
,
page
.
tags
?
page
.
tags
.
map
(
t
=>
t
.
tag
).
join
(
', '
)
:
''
],
[
'editor'
,
page
.
editorKey
],
[
'dateCreated'
,
page
.
createdAt
]
,
[
'dateCreated'
,
page
.
createdAt
]
]
switch
(
page
.
contentType
)
{
case
'markdown'
:
...
...
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