handle remote links in ts pages

Required to avoid loading remote links embedded in deck descriptions
in the webview
This commit is contained in:
Damien Elmes 2021-02-06 15:03:21 +10:00
parent ded626f0b9
commit e30b7fc36a

View File

@ -114,7 +114,7 @@ class AnkiWebPage(QWebEnginePage):
def acceptNavigationRequest( def acceptNavigationRequest(
self, url: QUrl, navType: Any, isMainFrame: bool self, url: QUrl, navType: Any, isMainFrame: bool
) -> bool: ) -> bool:
if not self.open_links_externally: if not self.open_links_externally or "_anki/pages" in url.path():
return super().acceptNavigationRequest(url, navType, isMainFrame) return super().acceptNavigationRequest(url, navType, isMainFrame)
if not isMainFrame: if not isMainFrame:
@ -636,7 +636,7 @@ document.head.appendChild(style);
def load_ts_page(self, name: str) -> None: def load_ts_page(self, name: str) -> None:
from aqt import mw from aqt import mw
self.set_open_links_externally(False) self.set_open_links_externally(True)
if theme_manager.night_mode: if theme_manager.night_mode:
extra = "#night" extra = "#night"
else: else: