mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
When generating ICU sort keys handle strings with NULL bytes in them
This commit is contained in:
parent
872a1434c7
commit
f754786d12
@ -71,10 +71,16 @@ def icu_sort_key(collator, obj):
|
|||||||
if not obj:
|
if not obj:
|
||||||
return _none2
|
return _none2
|
||||||
try:
|
try:
|
||||||
|
try:
|
||||||
|
return _secondary_collator.sort_key(obj)
|
||||||
|
except AttributeError:
|
||||||
|
return secondary_collator().sort_key(obj)
|
||||||
|
except TypeError:
|
||||||
|
if isinstance(obj, unicode):
|
||||||
|
obj = obj.replace(u'\0', u'')
|
||||||
|
else:
|
||||||
|
obj = obj.replace(b'\0', b'')
|
||||||
return _secondary_collator.sort_key(obj)
|
return _secondary_collator.sort_key(obj)
|
||||||
except AttributeError:
|
|
||||||
return secondary_collator().sort_key(obj)
|
|
||||||
|
|
||||||
|
|
||||||
def py_find(pattern, source):
|
def py_find(pattern, source):
|
||||||
pos = source.find(pattern)
|
pos = source.find(pattern)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user