mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #4832 (Namespace-qualified OCF container file in ePub crashes ebook-meta)
This commit is contained in:
parent
768e01482d
commit
8050aac496
@ -5,7 +5,7 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
'''Read meta information from epub files'''
|
||||
|
||||
import os
|
||||
import os, re
|
||||
from cStringIO import StringIO
|
||||
from contextlib import closing
|
||||
|
||||
@ -29,15 +29,15 @@ class Container(dict):
|
||||
def __init__(self, stream=None):
|
||||
if not stream: return
|
||||
soup = BeautifulStoneSoup(stream.read())
|
||||
container = soup.find('container')
|
||||
container = soup.find(name=re.compile(r'container$', re.I))
|
||||
if not container:
|
||||
raise OCFException("<container/> element missing")
|
||||
raise OCFException("<container> element missing")
|
||||
if container.get('version', None) != '1.0':
|
||||
raise EPubException("unsupported version of OCF")
|
||||
rootfiles = container.find('rootfiles')
|
||||
rootfiles = container.find(re.compile(r'rootfiles$', re.I))
|
||||
if not rootfiles:
|
||||
raise EPubException("<rootfiles/> element missing")
|
||||
for rootfile in rootfiles.findAll('rootfile'):
|
||||
for rootfile in rootfiles.findAll(re.compile(r'rootfile$', re.I)):
|
||||
try:
|
||||
self[rootfile['media-type']] = rootfile['full-path']
|
||||
except KeyError:
|
||||
|
Loading…
x
Reference in New Issue
Block a user