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

Merged
merged 2 commits into from Mar 18, 2013

Conversation

Projects
None yet
4 participants
Owner

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.

Owner

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.
1a0c9e6

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

1 check passed

default The Travis build passed
Details

@nuklea nuklea commented on the diff Apr 15, 2013

compressor/templatetags/compress.py
@@ -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

nuklea Apr 15, 2013

Contributor

This is doesn't work!

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