Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixed #19526 #809

Merged
merged 1 commit into from

2 participants

@asendecka

CSS specifications governs that syntax is case insensitive.
This modifies CachedFilesMixin to support that.

@asendecka asendecka Fixed #19526
CSS specifications governs that syntax is case insensitive.
This modifies CachedFilesMixin to support that.
32a7ab2
@HonzaKral HonzaKral merged commit 83ecb7b into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 23, 2013
  1. @asendecka

    Fixed #19526

    asendecka authored
    CSS specifications governs that syntax is case insensitive.
    This modifies CachedFilesMixin to support that.
This page is out of date. Refresh to see the latest.
View
2  django/contrib/staticfiles/storage.py
@@ -71,7 +71,7 @@ def __init__(self, *args, **kwargs):
pattern, template = pattern
else:
template = self.default_template
- compiled = re.compile(pattern)
+ compiled = re.compile(pattern, re.IGNORECASE)
self._patterns.setdefault(extension, []).append((compiled, template))
def file_hash(self, name, content=None):
View
1  tests/regressiontests/staticfiles_tests/project/documents/cached/styles_insensitive.css
@@ -0,0 +1 @@
+@IMporT uRL("other.css");
View
8 tests/regressiontests/staticfiles_tests/tests.py
@@ -542,6 +542,14 @@ def test_cache_key_memcache_validation(self):
cache_validator.validate_key(cache_key)
self.assertEqual(cache_key, 'staticfiles:821ea71ef36f95b3922a77f7364670e7')
+ def test_css_import_case_insensitive(self):
+ relpath = self.cached_file_path("cached/styles_insensitive.css")
+ self.assertEqual(relpath, "cached/styles_insensitive.2f0151cca872.css")
+ with storage.staticfiles_storage.open(relpath) as relfile:
+ content = relfile.read()
+ self.assertNotIn(b"cached/other.css", content)
+ self.assertIn(b"other.d41d8cd98f00.css", content)
+
# we set DEBUG to False here since the template tag wouldn't work otherwise
@override_settings(**dict(TEST_SETTINGS,
Something went wrong with that request. Please try again.