~lifeless/python-oops-tools/bug-1003627

« back to all changes in this revision

Viewing changes to src/oopstools/oops/dbsummaries.py

  • Committer: Tarmac
  • Author(s): Martin Packman
  • Date: 2011-12-15 12:50:52 UTC
  • mfrom: (27.2.6 python-oops-tools)
  • Revision ID: launchpad@pqm.canonical.com-20111215125052-3uso1kf6dfjimbsq
Encode output of analyse_error_reports as UTF-8.

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
 
43
43
def _escape(value):
44
44
    if value is not None:
 
45
        if not isinstance(value, unicode):
 
46
            # If a random byte string gets here, ensure it's ascii. Latin-1 is
 
47
            # used to decode so the escaped form matches the original bytes.
 
48
            value = value.decode("latin1").encode("ascii", "backslashreplace")
 
49
        else:
 
50
            value = value.encode("utf-8")
45
51
        value = cgi.escape(value)
46
52
    return value
47
53
 
656
662
        fp.write('<html>\n'
657
663
                 '<head>\n'
658
664
                 '<title>Oops Report Summary</title>\n'
 
665
                 '<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />\n'
659
666
                 '<link rel="stylesheet" type="text/css" href="%s/oops/static/oops.css" />\n'
660
667
                 '</head>\n'
661
668
                 '<body>\n'