mirror of
https://github.com/moparisthebest/SickRage
synced 2025-01-05 10:58:01 -05:00
SiCKRAGETV/sickrage-issues#86 - Fixed WebUI encoding issues with template filter.
This commit is contained in:
parent
3d293af71b
commit
b255f5d0f8
@ -81,15 +81,15 @@ route_locks = {}
|
||||
|
||||
class html_entities(CheetahFilter):
|
||||
def filter(self, val, **dummy_kw):
|
||||
"""Filter incoming strings so they use HTML entity characters"""
|
||||
if isinstance(val, unicode):
|
||||
filtered = val.encode('ascii', 'xmlcharrefreplace')
|
||||
elif val is None:
|
||||
filtered = ''
|
||||
elif isinstance(val, str):
|
||||
filtered = val.decode('utf-8').encode('ascii', 'xmlcharrefreplace')
|
||||
filtered = val.decode(sickbeard.SYS_ENCODING).encode('ascii', 'xmlcharrefreplace')
|
||||
else:
|
||||
filtered = self.filter(str(val))
|
||||
|
||||
return filtered
|
||||
|
||||
class PageTemplate(CheetahTemplate):
|
||||
|
@ -1,3 +1,4 @@
|
||||
# coding=utf-8
|
||||
import locale
|
||||
import unittest
|
||||
import sys, os.path
|
||||
@ -13,7 +14,7 @@ from sickbeard.helpers import sanitizeFileName
|
||||
class EncodingTests(unittest.TestCase):
|
||||
def test_encoding(self):
|
||||
rootDir = 'C:\\Temp\\TV'
|
||||
strings = [u'Les Enfants De La T\xe9l\xe9']
|
||||
strings = [u'Les Enfants De La T\xe9l\xe9', u'RT<EFBFBD> One']
|
||||
|
||||
sickbeard.SYS_ENCODING = None
|
||||
|
||||
@ -40,6 +41,7 @@ class EncodingTests(unittest.TestCase):
|
||||
|
||||
for s in strings:
|
||||
try:
|
||||
show_name = s.decode(sickbeard.SYS_ENCODING, 'xmlcharrefreplace')
|
||||
show_dir = ek.ek(os.path.join, rootDir, sanitizeFileName(s))
|
||||
self.assertTrue(isinstance(show_dir, unicode))
|
||||
except Exception, e:
|
||||
|
Loading…
Reference in New Issue
Block a user