Commits

Olemis Lang committed f6c3a22

Safe handling of MIME charsets when reading attachment contents

  • Participants
  • Parent commits dfdb6b2
  • Branches providers

Comments (0)

Files changed (1)

File trac-dev/gviz/tracgviz/attachment.py

         except :
           content+= fd.read()
         else :
-          content = UTF8Recoder(fd, mimesys.get_charset(content, mimetype))
+          import codecs
+          fd.close()
+          charset = mimesys.get_charset(content, mimetype)
+          fd = codecs.open(a.path, 'rb', encoding=charset)
+          content = UTF8Recoder(fd, 'unicode-internal')
         (cols, data), mimetype, ext = mimesys.convert_content(
                                                   req, mimetype, \
                                                   content, 'trac.gviz')