mirror of
https://github.com/django/django.git
synced 2025-06-05 11:39:13 +00:00
Fixed #34407 -- Reported filename when decoding fails in collectstatic's post_process.
This commit is contained in:
parent
4db33e96d1
commit
03bc92af97
@ -353,7 +353,10 @@ class HashedFilesMixin:
|
|||||||
# ..to apply each replacement pattern to the content
|
# ..to apply each replacement pattern to the content
|
||||||
if name in adjustable_paths:
|
if name in adjustable_paths:
|
||||||
old_hashed_name = hashed_name
|
old_hashed_name = hashed_name
|
||||||
content = original_file.read().decode("utf-8")
|
try:
|
||||||
|
content = original_file.read().decode("utf-8")
|
||||||
|
except UnicodeDecodeError as exc:
|
||||||
|
yield name, None, exc, False
|
||||||
for extension, patterns in self._patterns.items():
|
for extension, patterns in self._patterns.items():
|
||||||
if matches_patterns(path, (extension,)):
|
if matches_patterns(path, (extension,)):
|
||||||
for pattern, template in patterns:
|
for pattern, template in patterns:
|
||||||
|
2
tests/staticfiles_tests/project/nonutf8/nonutf8.css
Normal file
2
tests/staticfiles_tests/project/nonutf8/nonutf8.css
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/* éviter écrasement */
|
||||||
|
.test { margin: 1 rem; }
|
@ -368,6 +368,18 @@ class TestHashedFiles:
|
|||||||
self.assertEqual("Post-processing 'faulty.css' failed!\n\n", err.getvalue())
|
self.assertEqual("Post-processing 'faulty.css' failed!\n\n", err.getvalue())
|
||||||
self.assertPostCondition()
|
self.assertPostCondition()
|
||||||
|
|
||||||
|
@override_settings(
|
||||||
|
STATICFILES_DIRS=[os.path.join(TEST_ROOT, "project", "nonutf8")],
|
||||||
|
STATICFILES_FINDERS=["django.contrib.staticfiles.finders.FileSystemFinder"],
|
||||||
|
)
|
||||||
|
def test_post_processing_nonutf8(self):
|
||||||
|
finders.get_finder.cache_clear()
|
||||||
|
err = StringIO()
|
||||||
|
with self.assertRaises(UnicodeDecodeError):
|
||||||
|
call_command("collectstatic", interactive=False, verbosity=0, stderr=err)
|
||||||
|
self.assertEqual("Post-processing 'nonutf8.css' failed!\n\n", err.getvalue())
|
||||||
|
self.assertPostCondition()
|
||||||
|
|
||||||
|
|
||||||
@override_settings(
|
@override_settings(
|
||||||
STORAGES={
|
STORAGES={
|
||||||
|
Loading…
x
Reference in New Issue
Block a user