Changeset f503585


Ignore:
Timestamp:
2011-01-21T14:17:03Z (14 years ago)
Author:
Miklos Vajna <vmiklos@…>
Branches:
master
Children:
7279554
Parents:
a86612f
git-author:
Philippe Crama <pcfeb0009@…> (21-01-11 14:17:03)
git-committer:
Miklos Vajna <vmiklos@…> (21-01-11 14:17:03)
Message:

Avoid debugging output charset problems crashing skyped.py

When using irssi in an LC_CTYPE=ISO-8859-1 terminal (thus
/set charset iso-8859-1 for irssi, set charset iso-8859-1 for
bitlbee and no recode_out_default_charset set for irssi) and
skyped.py in a Windows console window (CP1252?), sending a
message with a &eacute; (the character, not the HTML entity)
crashes the server because in its debugging output it tries to
print the UTF-8 equivalent intepreted as CP1252 code points.

I do not think that the "if options.log: ..." code just below the
patch needs the same treatment as the worst that can happen is
that some messages in the log file will be garbled. Since I do
not use/test that code path, I didn't touch it.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • skype/skyped.py

    ra86612f rf503585  
    199199
    200200        if options.debug:
    201                 print now + ": " + msg
     201                try:
     202                        print now + ": " + msg
     203                except Exception, s:
     204                        try:
     205                                sanitized = msg.encode("ascii", "backslashreplace")
     206                        except Error, s:
     207                                try:
     208                                        sanitized = "hex [" + msg.encode("hex") + "]"
     209                                except Error, s:
     210                                        sanitized = "[unable to print debug message]"
     211                        print now + "~=" + sanitized
    202212                sys.stdout.flush()
    203213        if options.log:
Note: See TracChangeset for help on using the changeset viewer.