Edit Book: Fix error when checking spelling if one of the files in the book declares an invalid (empty) language code. Fixes #1316170 [Spellcheck doesn't like ...xml:lang=""](https://bugs.launchpad.net/calibre/+bug/1316170)

This commit is contained in:
Kovid Goyal 2014-05-05 20:31:25 +05:30
parent a0f94d0c5b
commit c33dd12449

View File

@ -128,11 +128,17 @@ def read_words_from_html_tag(tag, words, file_name, parent_locale, locale):
def locale_from_tag(tag):
if 'lang' in tag.attrib:
loc = parse_lang_code(tag.get('lang'))
try:
loc = parse_lang_code(tag.get('lang'))
except ValueError:
loc = None
if loc is not None:
return loc
if '{http://www.w3.org/XML/1998/namespace}lang' in tag.attrib:
loc = parse_lang_code(tag.get('{http://www.w3.org/XML/1998/namespace}lang'))
try:
loc = parse_lang_code(tag.get('{http://www.w3.org/XML/1998/namespace}lang'))
except ValueError:
loc = None
if loc is not None:
return loc