mirror of
https://github.com/moparisthebest/SickRage
synced 2025-01-08 04:18:09 -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):
|
class html_entities(CheetahFilter):
|
||||||
def filter(self, val, **dummy_kw):
|
def filter(self, val, **dummy_kw):
|
||||||
"""Filter incoming strings so they use HTML entity characters"""
|
|
||||||
if isinstance(val, unicode):
|
if isinstance(val, unicode):
|
||||||
filtered = val.encode('ascii', 'xmlcharrefreplace')
|
filtered = val.encode('ascii', 'xmlcharrefreplace')
|
||||||
elif val is None:
|
elif val is None:
|
||||||
filtered = ''
|
filtered = ''
|
||||||
elif isinstance(val, str):
|
elif isinstance(val, str):
|
||||||
filtered = val.decode('utf-8').encode('ascii', 'xmlcharrefreplace')
|
filtered = val.decode(sickbeard.SYS_ENCODING).encode('ascii', 'xmlcharrefreplace')
|
||||||
else:
|
else:
|
||||||
filtered = self.filter(str(val))
|
filtered = self.filter(str(val))
|
||||||
|
|
||||||
return filtered
|
return filtered
|
||||||
|
|
||||||
class PageTemplate(CheetahTemplate):
|
class PageTemplate(CheetahTemplate):
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# coding=utf-8
|
||||||
import locale
|
import locale
|
||||||
import unittest
|
import unittest
|
||||||
import sys, os.path
|
import sys, os.path
|
||||||
@ -13,7 +14,7 @@ from sickbeard.helpers import sanitizeFileName
|
|||||||
class EncodingTests(unittest.TestCase):
|
class EncodingTests(unittest.TestCase):
|
||||||
def test_encoding(self):
|
def test_encoding(self):
|
||||||
rootDir = 'C:\\Temp\\TV'
|
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
|
sickbeard.SYS_ENCODING = None
|
||||||
|
|
||||||
@ -40,6 +41,7 @@ class EncodingTests(unittest.TestCase):
|
|||||||
|
|
||||||
for s in strings:
|
for s in strings:
|
||||||
try:
|
try:
|
||||||
|
show_name = s.decode(sickbeard.SYS_ENCODING, 'xmlcharrefreplace')
|
||||||
show_dir = ek.ek(os.path.join, rootDir, sanitizeFileName(s))
|
show_dir = ek.ek(os.path.join, rootDir, sanitizeFileName(s))
|
||||||
self.assertTrue(isinstance(show_dir, unicode))
|
self.assertTrue(isinstance(show_dir, unicode))
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
|
Loading…
Reference in New Issue
Block a user