Anonymous avatar Anonymous committed 420e901

0.12.3dev: Added explicit encodings when rendering Genshi streams, for compatibility with Genshi trunk.

Comments (0)

Files changed (6)

 
         out = StringIO()
         stream = Stream(XMLParser(fileobj))
-        stream.select('//script[@type="text/javascript"]').render(out=out)
+        stream = stream.select('//script[@type="text/javascript"]')
+        stream.render(out=out, encoding='utf-8')
         out.seek(0)
         return extract_javascript(out, keywords, comment_tags, options)
 
             stream = template.generate(**data)
             out = file(dest, 'w')
             try:
-                stream.render('text', out=out)
+                stream.render('text', out=out, encoding='utf-8')
             finally:
                 out.close()
     

trac/notification.py

     def encode_header(self, key, value):
         if isinstance(value, tuple):
             return self.format_header(key, value[0], value[1])
-        if isinstance(value, list):
-            items = []
-            for v in value:
-                items.append(self.encode_header(v))
-            return ',\n\t'.join(items)
         mo = self.longaddr_re.match(value)
         if mo:
             return self.format_header(key, mo.group(1), mo.group(2))
         # don't translate the e-mail stream
         t = deactivate()
         try:
-            body = stream.render('text')
+            body = stream.render('text', encoding='utf-8')
         finally:
             reactivate(t)
         projname = self.env.project_name

trac/versioncontrol/web_ui/changeset.py

             stream = Chrome(self.env).render_template(req, 'changeset.html',
                                                       data, fragment=True)
             content = stream.select('//div[@id="content"]')
-            str_content = content.render('xhtml')
+            str_content = content.render('xhtml', encoding='utf-8')
             req.send_header('Content-Length', len(str_content))
             req.end_headers()
             req.write(str_content)
                  for (isdir, name, path) in sorted(entries, key=kind_order)
                  if name.lower().startswith(prefix)])
 
-            xhtml = elem.generate().render('xhtml')
+            xhtml = elem.generate().render('xhtml', encoding='utf-8')
             req.send_header('Content-Length', len(xhtml))
             req.write(xhtml)
             return

trac/web/chrome.py

 
         if method == 'text':
             buffer = StringIO()
-            stream.render('text', out=buffer)
+            stream.render('text', out=buffer, encoding='utf-8')
             return buffer.getvalue()
 
         doctype = {'text/html': DocType.XHTML_STRICT}.get(content_type)
 
         try:
             buffer = StringIO()
-            stream.render(method, doctype=doctype, out=buffer)
+            stream.render(method, doctype=doctype, out=buffer,
+                          encoding='utf-8')
             return buffer.getvalue().translate(_translate_nop,
                                                _invalid_control_chars)
         except Exception, e:
         loader = TemplateLoader(loadpaths, variable_lookup='lenient')
         tmpl = loader.load(template)
         stream = tmpl.generate(**data)
-        output = stream.render('xhtml', doctype=DocType.XHTML_STRICT)
+        output = stream.render('xhtml', doctype=DocType.XHTML_STRICT,
+                               encoding='utf-8')
         req.send(output, 'text/html')
 
     except RequestDone:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.