mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
PDF Output: Remove JS from HTML files before passing them to WebKit
This commit is contained in:
parent
c2e36408d3
commit
3d586aa15a
@ -270,6 +270,18 @@ class PDFOutput(OutputFormatPlugin):
|
||||
if hasattr(root, 'xpath') and margins:
|
||||
root.set('data-calibre-pdf-output-page-margins', json.dumps(margins))
|
||||
|
||||
# Remove javascript
|
||||
for item in self.oeb.spine:
|
||||
root = item.data
|
||||
if hasattr(root, 'xpath'):
|
||||
for script in root.xpath('//*[local-name()="script"]'):
|
||||
script.text = None
|
||||
script.attrib.clear()
|
||||
for elem in root.iter('*'):
|
||||
for attr in tuple(elem.attrib):
|
||||
if attr.startswith('on'):
|
||||
elem.set(attr, '')
|
||||
|
||||
with TemporaryDirectory('_pdf_out') as oeb_dir:
|
||||
from calibre.customize.ui import plugin_for_output_format
|
||||
oeb_output = plugin_for_output_format('oeb')
|
||||
|
Loading…
x
Reference in New Issue
Block a user