Commit 929eb1da by Victor Shnayder Committed by Timothée Peignier

Fix unicode encoding bug

* re.sub needs to take a unicode string, not a byte string
parent 337d7224
...@@ -5,7 +5,7 @@ import subprocess ...@@ -5,7 +5,7 @@ import subprocess
from itertools import takewhile from itertools import takewhile
from django.utils.encoding import smart_str from django.utils.encoding import smart_str, force_unicode
try: try:
from staticfiles import finders from staticfiles import finders
...@@ -133,7 +133,8 @@ class Compressor(object): ...@@ -133,7 +133,8 @@ class Compressor(object):
output_filename, variant) output_filename, variant)
return "url(%s)" % asset_url return "url(%s)" % asset_url
content = self.read_file(path) content = self.read_file(path)
content = re.sub(URL_DETECTOR, reconstruct, smart_str(content)) # content needs to be unicode to avoid explosions with non-ascii chars
content = re.sub(URL_DETECTOR, reconstruct, force_unicode(content))
stylesheets.append(content) stylesheets.append(content)
return '\n'.join(stylesheets) return '\n'.join(stylesheets)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment