fix more encoding problems

This commit is contained in:
Carl Meyer
2009-11-05 23:33:49 -05:00
parent 43bbf1bfed
commit feadb4747e
5 changed files with 9 additions and 6 deletions

View File

@@ -80,7 +80,9 @@ class Compressor(object):
return self._hunks
def concat(self):
return "\n".join(self.hunks)
# if any of the hunks are unicode, all of them will be coerced
# this breaks any hunks with non-ASCII data in them
return "\n".join([str(hunk) for hunk in self.hunks])
def filter(self, content, method, **kwargs):
content = content

View File

@@ -38,4 +38,4 @@ class CssMediaFilter(FilterBase):
self.media = elem['media']
except (TypeError, KeyError):
return self.content
return "@media %s {%s}" % (self.media, self.content)
return "@media %s {%s}" % (str(self.media), self.content)

View File

@@ -136,7 +136,6 @@ class CssMediaTestCase(TestCase):
out = u'@media screen {body { background:#990; }}\n@media print {p { border:5px solid green;}}\n@media all {body { color:#fff; }}'
self.assertEqual(out, self.cssNode.combined)
class TemplatetagTestCase(TestCase):
def setUp(self):
settings.COMPRESS = True
@@ -163,11 +162,12 @@ class TemplatetagTestCase(TestCase):
def test_nonascii_css_tag(self):
template = u"""{% load compress %}{% compress css %}
<link rel="stylesheet" href="{{ MEDIA_URL }}css/nonasc.css" type="text/css" charset="utf-8">
<link rel="stylesheet" href="{{ MEDIA_URL }}css/nonasc.css" type="text/css" media="print" charset="utf-8">
<style type="text/css">p { border:5px solid green;}</style>
{% endcompress %}
"""
context = { 'MEDIA_URL': settings.MEDIA_URL }
out = '<link rel="stylesheet" href="/media/CACHE/css/fc35bb10bce9.css" type="text/css" media="all" charset="utf-8">'
out = '<link rel="stylesheet" href="/media/CACHE/css/68da639dbb24.css" type="text/css" media="all" charset="utf-8">'
self.assertEqual(out, self.render(template, context))
def test_js_tag(self):

View File

@@ -1,2 +1 @@
p { background: url( '../../images/test.png' ); }
.byline:before { content: " — "; }

View File

@@ -0,0 +1,2 @@
p { background: url( '../../images/test.png' ); }
.byline:before { content: " — "; }