mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
E-book viewer/Content server: Disallow browser native context menu when right clicking in sandboxed iframes. Fixes #2033530 [E-book viewer: right-clicking in book metadata view opens a context menu](https://bugs.launchpad.net/calibre/+bug/2033530)
This commit is contained in:
parent
e1d8b44561
commit
fef4b97a03
@ -240,6 +240,9 @@ def sandboxed_html(html, style, sandbox):
|
|||||||
css = 'html, body { margin: 0; padding: 0; font-family: __FONT__ } p:first-child { margin-top: 0; padding-top: 0; -webkit-margin-before: 0 }'.replace('__FONT__', get_font_family())
|
css = 'html, body { margin: 0; padding: 0; font-family: __FONT__ } p:first-child { margin-top: 0; padding-top: 0; -webkit-margin-before: 0 }'.replace('__FONT__', get_font_family())
|
||||||
css += style or ''
|
css += style or ''
|
||||||
final_html = f'<!DOCTYPE html><html><head><style>{css}</style></head><body>{html}</body></html>'
|
final_html = f'<!DOCTYPE html><html><head><style>{css}</style></head><body>{html}</body></html>'
|
||||||
# Microsoft Edge does not support srcdoc not does it work using a data URI.
|
# prevent context menu on right click in iframe
|
||||||
|
ans.addEventListener('load', def(ev):
|
||||||
|
ev.target.contentWindow.addEventListener('contextmenu', def(e): e.preventDefault();)
|
||||||
|
)
|
||||||
ans.srcdoc = final_html
|
ans.srcdoc = final_html
|
||||||
return ans
|
return ans
|
||||||
|
Loading…
x
Reference in New Issue
Block a user