mirror of
				https://github.com/kovidgoyal/calibre.git
				synced 2025-11-03 19:17:02 -05:00 
			
		
		
		
	EPUB Input: Fix error when processing EPUB files that uses non-ascii characters for their unique ids. Fixes #1540496 [Private bug](https://bugs.launchpad.net/calibre/+bug/1540496)
This commit is contained in:
		
							parent
							
								
									85b91e4c75
								
							
						
					
					
						commit
						dfd3be5b56
					
				@ -20,7 +20,7 @@ from calibre.ebooks.metadata import string_to_authors, MetaInformation, check_is
 | 
				
			|||||||
from calibre.ebooks.metadata.book.base import Metadata
 | 
					from calibre.ebooks.metadata.book.base import Metadata
 | 
				
			||||||
from calibre.utils.date import parse_date, isoformat
 | 
					from calibre.utils.date import parse_date, isoformat
 | 
				
			||||||
from calibre.utils.localization import get_lang, canonicalize_lang
 | 
					from calibre.utils.localization import get_lang, canonicalize_lang
 | 
				
			||||||
from calibre import prints, guess_type
 | 
					from calibre import prints, guess_type, prepare_string_for_xml
 | 
				
			||||||
from calibre.utils.cleantext import clean_ascii_chars, clean_xml_chars
 | 
					from calibre.utils.cleantext import clean_ascii_chars, clean_xml_chars
 | 
				
			||||||
from calibre.utils.config import tweaks
 | 
					from calibre.utils.config import tweaks
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1120,7 +1120,7 @@ class OPF(object):  # {{{
 | 
				
			|||||||
                uuid_elem = self.root.attrib[attr]
 | 
					                uuid_elem = self.root.attrib[attr]
 | 
				
			||||||
                break
 | 
					                break
 | 
				
			||||||
        if uuid_elem:
 | 
					        if uuid_elem:
 | 
				
			||||||
            matches = self.root.xpath('//*[@id=%r]'%uuid_elem)
 | 
					            matches = self.root.xpath('//*[@id="%s"]'%prepare_string_for_xml(uuid_elem, True))
 | 
				
			||||||
            if matches:
 | 
					            if matches:
 | 
				
			||||||
                for m in matches:
 | 
					                for m in matches:
 | 
				
			||||||
                    raw = m.text
 | 
					                    raw = m.text
 | 
				
			||||||
 | 
				
			|||||||
@ -16,7 +16,7 @@ from future_builtins import zip
 | 
				
			|||||||
from lxml import etree
 | 
					from lxml import etree
 | 
				
			||||||
from cssutils import replaceUrls, getUrls
 | 
					from cssutils import replaceUrls, getUrls
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from calibre import CurrentDir
 | 
					from calibre import CurrentDir, prepare_string_for_xml
 | 
				
			||||||
from calibre.constants import iswindows
 | 
					from calibre.constants import iswindows
 | 
				
			||||||
from calibre.customize.ui import (plugin_for_input_format, plugin_for_output_format)
 | 
					from calibre.customize.ui import (plugin_for_input_format, plugin_for_output_format)
 | 
				
			||||||
from calibre.ebooks.chardet import xml_to_unicode
 | 
					from calibre.ebooks.chardet import xml_to_unicode
 | 
				
			||||||
@ -1103,7 +1103,7 @@ class EpubContainer(Container):
 | 
				
			|||||||
                package_id = val
 | 
					                package_id = val
 | 
				
			||||||
                break
 | 
					                break
 | 
				
			||||||
        if package_id is not None:
 | 
					        if package_id is not None:
 | 
				
			||||||
            for elem in self.opf_xpath('//*[@id=%r]'%package_id):
 | 
					            for elem in self.opf_xpath('//*[@id="%s"]'%prepare_string_for_xml(package_id, True)):
 | 
				
			||||||
                if elem.text:
 | 
					                if elem.text:
 | 
				
			||||||
                    raw_unique_identifier = elem.text
 | 
					                    raw_unique_identifier = elem.text
 | 
				
			||||||
                    break
 | 
					                    break
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user