mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Check if tokens are correct ascii
This commit is contained in:
parent
b857f8608f
commit
5784256e02
@ -779,12 +779,16 @@ class ProcessTokens:
|
|||||||
msg =_('Invalid RTF: document doesn\'t start with \\rtf \n')
|
msg =_('Invalid RTF: document doesn\'t start with \\rtf \n')
|
||||||
raise self.__exception_handler, msg
|
raise self.__exception_handler, msg
|
||||||
|
|
||||||
##token = self.evaluate_token(token)
|
|
||||||
the_index = token.find('\\ ')
|
the_index = token.find('\\ ')
|
||||||
if token is not None and the_index > -1:
|
if token is not None and the_index > -1:
|
||||||
msg ='Invalid RTF: token "\\ " not valid.\n'
|
msg =_('Invalid RTF: token "\\ " not valid.\n')
|
||||||
raise self.__exception_handler, msg
|
raise self.__exception_handler, msg
|
||||||
elif token[:1] == "\\":
|
elif token[:1] == "\\":
|
||||||
|
try:
|
||||||
|
token.decode('us-ascii')
|
||||||
|
except UnicodeError, msg:
|
||||||
|
msg = _('Invalid RTF: Tokens not ascii encoded.\n%s') % str(msg)
|
||||||
|
raise self.__exception_handler, msg
|
||||||
line = self.process_cw(token)
|
line = self.process_cw(token)
|
||||||
if line is not None:
|
if line is not None:
|
||||||
write_obj.write(line)
|
write_obj.write(line)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user