diff --git a/static/skin/viewer.js b/static/skin/viewer.js
index d1e7bb1ae..ee742d9bc 100644
--- a/static/skin/viewer.js
+++ b/static/skin/viewer.js
@@ -309,14 +309,22 @@ function setup_external_link_blocker() {
setupEventHandler(contentIframe.contentDocument, 'a', 'click', onClickEvent);
}
+function getBlockedUrl(catchExternalUrl) {
+ const p = new URLSearchParams(catchExternalUrl.split('?')[1]);
+ return p.get('source');
+}
+
function handleInterceptedExternalLink(catchExternalUrl) {
// The external link blocking page was loaded in the viewer iframe.
- // We need to get rid of the viewer taskbar and display the confirmation
- // page in the top frame.
- const urlpath = `${root}/` + catchExternalUrl;
+ // We need to get rid of the viewer taskbar and load in the top frame either
+ // the external resource or, if running in --blockexternal mode, the
+ // confirmation page
+ const url = viewerSettings.linkBlockingEnabled
+ ? `${root}/` + catchExternalUrl
+ : getBlockedUrl(catchExternalUrl);
history.back(); // drop from the browsing history the state where the
// external link catcher page is loaded in the iframe ...
- window.location = urlpath; // ... and load it in the top frame instead
+ window.location = url; // ... and load the target in the top frame instead
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/test/server.cpp b/test/server.cpp
index 862dd3ba5..ba3c95b3a 100644
--- a/test/server.cpp
+++ b/test/server.cpp
@@ -73,7 +73,7 @@ const ResourceCollection resources200Compressible{
{ DYNAMIC_CONTENT, "/ROOT%23%3F/skin/taskbar.css" },
{ STATIC_CONTENT, "/ROOT%23%3F/skin/taskbar.css?cacheid=bbdaf425" },
{ DYNAMIC_CONTENT, "/ROOT%23%3F/skin/viewer.js" },
- { STATIC_CONTENT, "/ROOT%23%3F/skin/viewer.js?cacheid=202f8641" },
+ { STATIC_CONTENT, "/ROOT%23%3F/skin/viewer.js?cacheid=aa7200e4" },
{ DYNAMIC_CONTENT, "/ROOT%23%3F/skin/fonts/Poppins.ttf" },
{ STATIC_CONTENT, "/ROOT%23%3F/skin/fonts/Poppins.ttf?cacheid=af705837" },
{ DYNAMIC_CONTENT, "/ROOT%23%3F/skin/fonts/Roboto.ttf" },
@@ -312,7 +312,7 @@ R"EXPECTEDRESULT(
-
+
const blankPageUrl = root + "/skin/blank.html?cacheid=6b1fa032";