Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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.
  • Loading branch information...
commit 3727f6d09681e4cb23d67e14ecc677a364c991bd 1 parent 0a68a29
@jezdez jezdez authored
View
2  django/contrib/staticfiles/storage.py
@@ -228,7 +228,7 @@ def post_process(self, paths, dry_run=False, **options):
# ..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:
View
5 tests/regressiontests/staticfiles_tests/apps/test/static/test/nonascii.css
@@ -0,0 +1,5 @@
+body {
+ background: url('window.png');
+}
+
+.snowman:before { content: ""; }
View
BIN  tests/regressiontests/staticfiles_tests/apps/test/static/test/window.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
5 tests/regressiontests/staticfiles_tests/tests.py
@@ -498,8 +498,9 @@ def test_post_processing(self):
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):
"""
Please sign in to comment.
Something went wrong with that request. Please try again.