Commit eb5df8e9 authored by Jannis Leidel's avatar Jannis Leidel
Browse files

Fixed the relative static file resolution of the CachedStaticFilesStorage...

Fixed the relative static file resolution of the CachedStaticFilesStorage backend and the post processing of deeply nested static files.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16862 bcc190cf-cafb-0310-a4f2-bffc1f526a37
parent 75199e8f
Loading
Loading
Loading
Loading
+16 −7
Original line number Diff line number Diff line
@@ -113,13 +113,22 @@ class CachedFilesMixin(object):
                return matched
            name_parts = name.split('/')
            # Using posix normpath here to remove duplicates
            result = url_parts = posixpath.normpath(url).split('/')
            level = url.count('..')
            if level:
                result = name_parts[:-level - 1] + url_parts[level:]
            elif name_parts[:-1]:
                result = name_parts[:-1] + url_parts[-1:]
            joined_result = '/'.join(result)
            url = posixpath.normpath(url)
            url_parts = url.split('/')
            parent_level, sub_level = url.count('..'), url.count('/')
            if url.startswith('/'):
                sub_level -= 1
                url_parts = url_parts[1:]
            if parent_level or not url.startswith('/'):
                start, end = parent_level + 1, parent_level
            else:
                if sub_level:
                    if sub_level == 1:
                        parent_level -= 1
                    start, end = parent_level, sub_level - 1
                else:
                    start, end = 1, sub_level - 1
            joined_result = '/'.join(name_parts[:-start] + url_parts[end:])
            hashed_url = self.url(joined_result, force=True)
            # Return the hashed and normalized version to the file
            return 'url("%s")' % hashed_url
+3 −0
Original line number Diff line number Diff line
body {
    background: #d3d6d8 url("img/window.png");
}
 No newline at end of file
+207 B
Loading image diff...
+4 −1
Original line number Diff line number Diff line
@import url("../cached/styles.css");
@import url("absolute.css");
body {
    background: #d3d6d8 url(img/relative.png);
}
 No newline at end of file
Loading