Fix #924: in-place imported files not playing under nginx when filename contains ? or %

This commit is contained in:
Eliot Berriot 2019-10-01 10:57:14 +02:00
parent 7b0f631b32
commit f0bea39d6a
No known key found for this signature in database
GPG key ID: DD6965E2476E5C27
3 changed files with 27 additions and 3 deletions

View file

@ -1,6 +1,6 @@
import datetime
import logging
import urllib
import urllib.parse
from django.conf import settings
from django.db import transaction
@ -321,6 +321,8 @@ def get_file_path(audio_file):
path = "/music" + audio_file.replace(prefix, "", 1)
if path.startswith("http://") or path.startswith("https://"):
return (settings.PROTECT_FILES_PATH + "/media/" + path).encode("utf-8")
# needed to serve files with % or ? chars
path = urllib.parse.quote(path)
return (settings.PROTECT_FILES_PATH + path).encode("utf-8")
if t == "apache2":
try: