Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
surfer-okd
Project
Project
Details
Activity
Releases
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
PUBLIC
surfer-okd
Commits
d755925f
Commit
d755925f
authored
Mar 01, 2016
by
Johannes Zellner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Properly check for absolute file paths
parent
24545229
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
1 deletion
+4
-1
actions.js
cli/actions.js
+1
-0
files.js
src/files.js
+3
-1
No files found.
cli/actions.js
View file @
d755925f
...
...
@@ -187,6 +187,7 @@ function del(filePath) {
superagent
.
del
(
config
.
server
()
+
API
+
relativeFilePath
).
query
(
gQuery
).
end
(
function
(
error
,
result
)
{
if
(
error
&&
error
.
status
===
401
)
return
console
.
log
(
'Login failed'
);
if
(
error
&&
error
.
status
===
404
)
return
console
.
log
(
'No such file or directory'
);
if
(
error
&&
error
.
status
===
403
)
return
console
.
log
(
'No such file or directory'
);
if
(
error
)
return
console
.
log
(
'Failed'
,
result
?
result
.
body
:
error
);
console
.
log
(
'Success. Removed %s files.'
,
result
.
body
.
entries
.
length
);
...
...
src/files.js
View file @
d755925f
...
...
@@ -106,7 +106,9 @@ function del(req, res, next) {
var
filePath
=
req
.
params
[
0
];
var
absoluteFilePath
=
getAbsolutePath
(
filePath
);
if
(
!
absoluteFilePath
)
return
next
(
new
HttpError
(
404
,
'Not found'
));
if
(
absoluteFilePath
.
slice
(
gBasePath
.
length
)
===
''
)
return
next
(
new
HttpError
(
403
,
'Forbidden'
));
// absoltueFilePath has to have the base path prepended
if
(
absoluteFilePath
.
length
<=
gBasePath
.
length
)
return
next
(
new
HttpError
(
403
,
'Forbidden'
));
fs
.
stat
(
absoluteFilePath
,
function
(
error
,
result
)
{
if
(
error
)
return
next
(
new
HttpError
(
404
,
error
));
...
...
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