Commit 2df681bf authored by Frederik Kriewitz's avatar Frederik Kriewitz Committed by Tomas Hlavacek
Browse files

gracefully handle non UTF-8 output of whois

Fixes exeptions like this (in case whois returns non utf-8 output):
ERROR in CGI: Traceback (most recent call last):
    File "/var/www/html/", line 775, in <module>
    File "/var/www/html/", line 738, in whois
    print self.runULGWhois(key,objtype)
    File "/var/www/html/", line 710, in runULGWhois
    res = whois.lookup(key)
    File "/var/www/html/", line 43, in lookup
    File "/usr/lib/python2.7/encodings/", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xf3 in position 24:
invalid continuation byte
Signed-off-by: Tomas Hlavacek's avatarTomas Hlavacek <>
parent 1a9d7416
......@@ -40,7 +40,7 @@ def lookup(key):
if(re.match('^\s*$',l) and not begin):
if(l[0] != '%'):
res=res+l.decode('utf-8', errors='replace')
begin = True
return res
......@@ -57,6 +57,6 @@ def lookup_as_name(asn):
m = asname_regex.match(l)
asname_cache[asn] =
return'utf-8', errors='replace')
return defaults.STRING_UNKNOWN
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment