mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Replace a few more dangerous uses of etree.Element
This commit is contained in:
parent
e7ad535834
commit
53c347420f
@ -9,7 +9,6 @@ __copyright__ = '2008, Marshall T. Vandegrift <llasram@gmail.com>'
|
||||
import os, re
|
||||
from urlparse import urldefrag
|
||||
|
||||
from lxml import etree
|
||||
from PyQt5.Qt import (
|
||||
Qt, QByteArray, QBuffer, QIODevice, QColor, QImage, QPainter, QSvgRenderer)
|
||||
from calibre.ebooks.oeb.base import XHTML, XLINK
|
||||
@ -171,7 +170,7 @@ class SVGRasterizer(object):
|
||||
href = os.path.splitext(item.href)[0] + '.png'
|
||||
id, href = manifest.generate(item.id, href)
|
||||
manifest.add(id, href, PNG_MIME, data=data)
|
||||
img = etree.Element(XHTML('img'), src=item.relhref(href))
|
||||
img = elem.makeelement(XHTML('img'), src=item.relhref(href))
|
||||
elem.getparent().replace(elem, img)
|
||||
for prop in ('width', 'height'):
|
||||
if prop in elem.attrib:
|
||||
|
@ -176,7 +176,7 @@ class DetectStructure(object):
|
||||
if chapter_mark == 'none':
|
||||
continue
|
||||
if chapter_mark == 'rule':
|
||||
mark = etree.Element(XHTML('hr'))
|
||||
mark = elem.makeelement(XHTML('hr'))
|
||||
elif chapter_mark == 'pagebreak':
|
||||
if c[item] < 3 and at_start(elem):
|
||||
# For the first two elements in this item, check if they
|
||||
@ -186,9 +186,9 @@ class DetectStructure(object):
|
||||
# feedbooks epubs match both a heading tag and its
|
||||
# containing div with the default chapter expression.
|
||||
continue
|
||||
mark = etree.Element(XHTML('div'), style=page_break_after)
|
||||
mark = elem.makeelement(XHTML('div'), style=page_break_after)
|
||||
else: # chapter_mark == 'both':
|
||||
mark = etree.Element(XHTML('hr'), style=page_break_before)
|
||||
mark = elem.makeelement(XHTML('hr'), style=page_break_before)
|
||||
try:
|
||||
elem.addprevious(mark)
|
||||
except TypeError:
|
||||
@ -321,5 +321,3 @@ class DetectStructure(object):
|
||||
level2.add(text, _href,
|
||||
play_order=self.oeb.toc.next_play_order())
|
||||
break
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user