1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-08-13 16:53:54 -04:00

Fixed issue #1024 - EncodingKludge issue identified and fixed

This commit is contained in:
echel0n 2014-12-12 20:25:44 -08:00
parent 0494f6f76c
commit 92a554da99
3 changed files with 13 additions and 12 deletions

View File

@ -63,15 +63,20 @@ def ss(x):
u_x = _toUnicode(x)
try:
return u_x.encode(sickbeard.SYS_ENCODING)
u_x_encoded = u_x.encode(sickbeard.SYS_ENCODING, 'xmlcharrefreplace')
except:
try:
return u_x.encode(sickbeard.SYS_ENCODING, 'replace')
u_x_encoded = u_x.encode(sickbeard.SYS_ENCODING)
except:
try:
return u_x.encode('utf-8', 'replace')
u_x_encoded = u_x.encode(sickbeard.SYS_ENCODING, 'replace')
except:
return x
try:
u_x_encoded = u_x.encode('utf-8', 'replace')
except:
u_x_encoded = x
return u_x_encoded
def fixListEncodings(x):
if not isinstance(x, (list, tuple)):

View File

@ -213,10 +213,7 @@ class WebHandler(BaseHandler):
def async_done(self, results):
try:
if results is not None:
try:
results = ek.ss(results).encode('utf-8', 'xmlcharrefreplace')
except:
results = str(results)
results = ek.ss(results)
self.finish(results)
except:

View File

@ -15,14 +15,13 @@ DEBUG = VERBOSE = False
class EncodingTests(unittest.TestCase):
def test_encoding(self):
strings = [u'הערוץ הראשון', 'Les Enfants De La Télé', u'\x89']
strings = [u'Les Enfants De La Télé']
for s in strings:
try:
print ek.ss(s)
print unicode(s).decode('UTF-8')
print 'Encoded: ' + ek.ss(s)
except Exception, e:
print ex(e)
ex(e)
if __name__ == "__main__":
print "=================="