X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/4fbd1c359e6f2b8b15536179021a6cb0bc3e390c..5e942ab9a9a217a8482a324c3e61fdd83c1c4247:/apps/catalogue/views.py?ds=sidebyside diff --git a/apps/catalogue/views.py b/apps/catalogue/views.py index 2e82dfa3..cf1ec128 100644 --- a/apps/catalogue/views.py +++ b/apps/catalogue/views.py @@ -21,6 +21,7 @@ from django.shortcuts import get_object_or_404, render, redirect from django.utils.encoding import force_str from django.utils.http import urlquote_plus from django.views.decorators.http import require_POST +from unidecode import unidecode from catalogue import forms from catalogue.forms import TagMultipleForm, TagSingleForm @@ -99,7 +100,10 @@ def create_missing(request): path = settings.MEDIA_ROOT + uppath if not os.path.isdir(path): os.makedirs(path) - dest_path = path + cover.name # UNSAFE + cover.name = unidecode(cover.name) + dest_path = path + cover.name + if not os.path.abspath(dest_path).startswith(os.path.abspath(path)): + raise Http404 with open(dest_path, 'w') as destination: for chunk in cover.chunks(): destination.write(chunk)