Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
ComfyUI
Commits
b1294fa4
Commit
b1294fa4
authored
Mar 14, 2023
by
m957ymj75urz
Browse files
fix path traversal for /view
parent
5b425aaa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
1 deletion
+5
-1
server.py
server.py
+5
-1
No files found.
server.py
View file @
b1294fa4
...
...
@@ -118,11 +118,15 @@ class PromptServer():
output_dir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
)),
type
)
if
"subfolder"
in
request
.
rel_url
.
query
:
output_dir
=
os
.
path
.
join
(
output_dir
,
request
.
rel_url
.
query
[
"subfolder"
])
full_output_dir
=
os
.
path
.
join
(
output_dir
,
request
.
rel_url
.
query
[
"subfolder"
])
if
os
.
path
.
commonpath
((
os
.
path
.
realpath
(
full_output_dir
),
output_dir
))
!=
output_dir
:
return
web
.
Response
(
status
=
403
)
output_dir
=
full_output_dir
file
=
request
.
rel_url
.
query
[
"file"
]
file
=
os
.
path
.
basename
(
file
)
file
=
os
.
path
.
join
(
output_dir
,
file
)
if
os
.
path
.
isfile
(
file
):
return
web
.
FileResponse
(
file
)
...
...
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