Bugfix: directories with the same name occuring multiple times in the path could be accidentally replaced and fubar'd

This commit is contained in:
Ryan McGrath 2015-06-10 17:09:31 +09:00
parent 1b7181302f
commit e74d062bcd
2 changed files with 4 additions and 4 deletions

View file

@ -208,13 +208,13 @@ class DjangoRedNoise(DjangoWhiteNoise):
""" """
file_path = None file_path = None
if self.debug: if self.debug:
file_path = finders.find(path.replace(self.static_prefix, '')) file_path = finders.find(path.replace(self.static_prefix, '', 1))
# The immediate assumption would be to just only do this in non-DEBUG # The immediate assumption would be to just only do this in non-DEBUG
# scenarios, but this here allows us to fall through to ROOT in DEBUG. # scenarios, but this here allows us to fall through to ROOT in DEBUG.
if file_path is None: if file_path is None:
file_path = ('%s/%s' % ( file_path = ('%s/%s' % (
self.static_root, path.replace(self.static_prefix, '') self.static_root, path.replace(self.static_prefix, '', 1)
)).replace('\\', '/') )).replace('\\', '/')
if not isfile(file_path): if not isfile(file_path):
@ -249,7 +249,7 @@ class DjangoRedNoise(DjangoWhiteNoise):
nature, so we have separate methods. nature, so we have separate methods.
""" """
file_path = ('%s/%s' % ( file_path = ('%s/%s' % (
self.media_root, path.replace(self.media_prefix, '') self.media_root, path.replace(self.media_prefix, '', 1)
)).replace('\\', '/') )).replace('\\', '/')
if isfile(file_path): if isfile(file_path):
files = {} files = {}

View file

@ -12,7 +12,7 @@ def read(*path):
setup( setup(
name='django-rednoise', name='django-rednoise',
version='1.0.4', version='1.0.5',
author='Ryan McGrath', author='Ryan McGrath',
author_email='ryan@venodesigns.net', author_email='ryan@venodesigns.net',
url='https://github.com/ryanmcgrath/django-rednoise/', url='https://github.com/ryanmcgrath/django-rednoise/',