Skip to content

Commit f43a90d

Browse files
committed
路径修复
1 parent 6bbfcb6 commit f43a90d

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

bin/docker_start.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22
NAME="djangoblog" # Name of the application
3-
DJANGODIR=/code/DjangoBlog # Django project directory
3+
DJANGODIR=/code/djangoBlog # Django project directory
44
USER=root # the user to run as
55
GROUP=root # the group to run as
66
NUM_WORKERS=1 # how many worker processes should Gunicorn spawn

blog/views.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
from django.views.generic.detail import DetailView
1515
from django.views.generic.list import ListView
1616

17-
from djangoblog.utils import cache, get_sha256, get_blog_setting
1817
from blog.models import Article, Category, Tag, Links, LinkShowType
1918
from comments.forms import CommentForm
19+
from djangoblog.utils import cache, get_sha256, get_blog_setting
2020

2121
logger = logging.getLogger(__name__)
2222

@@ -296,7 +296,9 @@ def fileupload(request):
296296
type='files' if not isimage else 'image', timestr=timestr, filename=filename)
297297
if not os.path.exists(basepath):
298298
os.makedirs(basepath)
299-
savepath = os.path.join(basepath, f"{uuid.uuid4().hex}{os.path.splitext(filename)[-1]}")
299+
savepath = os.path.normpath(os.path.join(basepath, f"{uuid.uuid4().hex}{os.path.splitext(filename)[-1]}"))
300+
if not savepath.startswith(basepath):
301+
return HttpResponse("only for post")
300302
with open(savepath, 'wb+') as wfile:
301303
for chunk in request.FILES[filename].chunks():
302304
wfile.write(chunk)

0 commit comments

Comments
 (0)