diff options
| author | Jannis Leidel <jannis@leidel.info> | 2012-07-08 12:56:49 +0200 |
|---|---|---|
| committer | Jannis Leidel <jannis@leidel.info> | 2012-07-08 12:56:49 +0200 |
| commit | 3727f6d09681e4cb23d67e14ecc677a364c991bd (patch) | |
| tree | 4b2dbf1005357ec4f8c0d7913ea73150787272ff | |
| parent | 0a68a2994be17ed2669accead331881cb0be41dd (diff) | |
Fixed #18430 -- Use the FILE_CHARSET setting when reading from a file during post processing with the cached staticfiles storage. Thanks to Brant Young for initial debugging.
| -rw-r--r-- | django/contrib/staticfiles/storage.py | 2 | ||||
| -rw-r--r-- | tests/regressiontests/staticfiles_tests/apps/test/static/test/nonascii.css | 5 | ||||
| -rw-r--r-- | tests/regressiontests/staticfiles_tests/apps/test/static/test/window.png | bin | 0 -> 207 bytes | |||
| -rw-r--r-- | tests/regressiontests/staticfiles_tests/tests.py | 5 |
4 files changed, 9 insertions, 3 deletions
diff --git a/django/contrib/staticfiles/storage.py b/django/contrib/staticfiles/storage.py index e02fec8ec0..16d33fff4b 100644 --- a/django/contrib/staticfiles/storage.py +++ b/django/contrib/staticfiles/storage.py @@ -228,7 +228,7 @@ class CachedFilesMixin(object): # ..to apply each replacement pattern to the content if name in adjustable_paths: - content = original_file.read() + content = original_file.read().decode(settings.FILE_CHARSET) converter = self.url_converter(name) for patterns in self._patterns.values(): for pattern in patterns: diff --git a/tests/regressiontests/staticfiles_tests/apps/test/static/test/nonascii.css b/tests/regressiontests/staticfiles_tests/apps/test/static/test/nonascii.css new file mode 100644 index 0000000000..a5358f6ede --- /dev/null +++ b/tests/regressiontests/staticfiles_tests/apps/test/static/test/nonascii.css @@ -0,0 +1,5 @@ +body { + background: url('window.png'); +} + +.snowman:before { content: "☃"; } diff --git a/tests/regressiontests/staticfiles_tests/apps/test/static/test/window.png b/tests/regressiontests/staticfiles_tests/apps/test/static/test/window.png Binary files differnew file mode 100644 index 0000000000..ba48325c0a --- /dev/null +++ b/tests/regressiontests/staticfiles_tests/apps/test/static/test/window.png diff --git a/tests/regressiontests/staticfiles_tests/tests.py b/tests/regressiontests/staticfiles_tests/tests.py index 7678d7f100..91435a2c86 100644 --- a/tests/regressiontests/staticfiles_tests/tests.py +++ b/tests/regressiontests/staticfiles_tests/tests.py @@ -498,8 +498,9 @@ class TestCollectionCachedStorage(BaseCollectionTestCase, collectstatic_cmd = CollectstaticCommand() collectstatic_cmd.set_options(**collectstatic_args) stats = collectstatic_cmd.collect() - self.assertTrue(os.path.join('cached', 'css', 'window.css') in stats['post_processed']) - self.assertTrue(os.path.join('cached', 'css', 'img', 'window.png') in stats['unmodified']) + self.assertIn(os.path.join('cached', 'css', 'window.css'), stats['post_processed']) + self.assertIn(os.path.join('cached', 'css', 'img', 'window.png'), stats['unmodified']) + self.assertIn(os.path.join('test', 'nonascii.css'), stats['post_processed']) def test_cache_key_memcache_validation(self): """ |
