Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #17865 -- Strip whitespaces from the paths when using the Cache…

…dStaticFilesStorage backend.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17696 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 7487c74020f97829e466c7efbdf7bd9e5fa90b1b 1 parent d174216
Jannis Leidel authored March 13, 2012
2  django/contrib/staticfiles/storage.py
@@ -67,7 +67,7 @@ def __init__(self, *args, **kwargs):
67 67
 
68 68
     def hashed_name(self, name, content=None):
69 69
         parsed_name = urlsplit(unquote(name))
70  
-        clean_name = parsed_name.path
  70
+        clean_name = parsed_name.path.strip()
71 71
         if content is None:
72 72
             if not self.exists(clean_name):
73 73
                 raise ValueError("The file '%s' could not be found with %r." %
3  tests/regressiontests/staticfiles_tests/project/documents/cached/denorm.css
... ...
@@ -1 +1,4 @@
1 1
 @import url("..//cached///styles.css");
  2
+body {
  3
+    background: #d3d6d8 url(img/relative.png );
  4
+}
4  tests/regressiontests/staticfiles_tests/tests.py
@@ -427,11 +427,13 @@ def test_template_tag_absolute(self):
427 427
 
428 428
     def test_template_tag_denorm(self):
429 429
         relpath = self.cached_file_path("cached/denorm.css")
430  
-        self.assertEqual(relpath, "cached/denorm.363de96e9b4b.css")
  430
+        self.assertEqual(relpath, "cached/denorm.c5bd139ad821.css")
431 431
         with storage.staticfiles_storage.open(relpath) as relfile:
432 432
             content = relfile.read()
433 433
             self.assertNotIn("..//cached///styles.css", content)
434 434
             self.assertIn("/static/cached/styles.93b1147e8552.css", content)
  435
+            self.assertNotIn("url(img/relative.png )", content)
  436
+            self.assertIn("/static/cached/img/relative.acae32e4532b.png", content)
435 437
 
436 438
     def test_template_tag_relative(self):
437 439
         relpath = self.cached_file_path("cached/relative.css")

0 notes on commit 7487c74

Please sign in to comment.
Something went wrong with that request. Please try again.