Fix UnicodeDecodeError with non-ascii content when using inline compression #375

merged 2 commits into from Mar 18, 2013


None yet
4 participants

diox commented Mar 18, 2013

This fixes a UnicodeDecodeError that happens if you are using the templatetag with the inline option and non-ascii content.

It appeared in #271, which was supposed to fix #270, which was a similar bug but with jinja2. The fix seems wrong to me: first, it only applies to one case - it doesn't affect cached result - and second the result is already an unicode string at this point (well, django.utils.safestring.SafeUnicode), so no decoding is necessary.

This fixes #305, I've included @marselester 's original failing test in the pull request, and that fixes it. In addition, it still passes the test originally added for #271.


diox commented Mar 18, 2013

Note: I guess this would also fix the error mentioned in #343.

@jezdez jezdez added a commit that referenced this pull request Mar 18, 2013

@jezdez jezdez Merge pull request #375 from diox/js-inline-non-ascii
Fix UnicodeDecodeError with non-ascii content when using inline compression. Fixes #375.

@jezdez jezdez merged commit 1a0c9e6 into django-compressor:develop Mar 18, 2013

1 check passed

default The Travis build passed

@nuklea nuklea commented on the diff Apr 15, 2013

@@ -107,7 +107,7 @@ def render_compressed(self, context, kind, mode, forced=False):
rendered_output = self.render_output(compressor, mode, forced=forced)
if cache_key:
cache_set(cache_key, rendered_output)
- return rendered_output.decode('utf-8')
+ return rendered_output

nuklea Apr 15, 2013


This is doesn't work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment