Fixed #17455 -- Extended CachedStaticFilesStorage slightly to handle some URLs better that are used to add support for webfonts to IE 6-8. Also ignore data: URLs and fragment-only URLs (e.g. #default#VML).

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17282 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jannis Leidel 2011-12-27 22:49:24 +00:00
parent ae0ce4373f
commit 46c12d1293
6 changed files with 33 additions and 6 deletions

View file

@ -0,0 +1 @@
not really a EOT ;)

View file

@ -0,0 +1 @@
not really a SVG ;)

View file

@ -0,0 +1,8 @@
@font-face {
src: url('fonts/font.eot?#iefix') format('embedded-opentype'),
url('fonts/font.svg#webfontIyfZbseF') format('svg');
url('data:font/woff;charset=utf-8;base64,d09GRgABAAAAADJoAA0AAAAAR2QAAQAAAAAAAAAAAAA');
}
div {
behavior: url("#default#VML");
}

View file

@ -4,7 +4,7 @@ from django.core.files import storage
class DummyStorage(storage.Storage):
"""
A storage class that does implement modified_time() but raises
NotImplementedError when calling
NotImplementedError when calling
"""
def _save(self, name, content):
return 'dummy'

View file

@ -331,6 +331,16 @@ class TestCollectionCachedStorage(BaseCollectionTestCase,
self.assertNotIn("cached/other.css", content)
self.assertIn("/static/cached/other.d41d8cd98f00.css", content)
def test_path_with_querystring_and_fragment(self):
relpath = self.cached_file_path("cached/css/fragments.css")
self.assertEqual(relpath, "cached/css/fragments.75433540b096.css")
with storage.staticfiles_storage.open(relpath) as relfile:
content = relfile.read()
self.assertIn('/static/cached/css/fonts/font.a4b0478549d0.eot?#iefix', content)
self.assertIn('/static/cached/css/fonts/font.b8d603e42714.svg#webfontIyfZbseF', content)
self.assertIn('data:font/woff;charset=utf-8;base64,d09GRgABAAAAADJoAA0AAAAAR2QAAQAAAAAAAAAAAAA', content)
self.assertIn('#default#VML', content)
def test_template_tag_absolute(self):
relpath = self.cached_file_path("cached/absolute.css")
self.assertEqual(relpath, "cached/absolute.cc80cb5e2eb1.css")