mirror of https://github.com/kiwix/libkiwix.git
Unblock external link in catch page in JS code
Instead of disabling the blocking for the handler, the JS code detects it is displaying the handler and allows external links to go through
This commit is contained in:
parent
412f0d9c61
commit
d04d9bf7f3
|
@ -392,7 +392,7 @@ Response InternalServer::build_500(const std::string& msg)
|
|||
{
|
||||
kainjow::mustache::data data;
|
||||
data.set("error", msg);
|
||||
Response response(m_root, true, false, false, false);
|
||||
Response response(m_root, true, false, false, m_blockExternalLinks);
|
||||
response.set_template(RESOURCE::templates::_500_html, data);
|
||||
response.set_mimeType("text/html");
|
||||
response.set_code(MHD_HTTP_INTERNAL_SERVER_ERROR);
|
||||
|
@ -732,7 +732,7 @@ Response InternalServer::handle_captured_external(const RequestContext& request)
|
|||
|
||||
auto data = get_default_data();
|
||||
data.set("source", source);
|
||||
Response response = Response(m_root, m_verbose.load(), m_withTaskbar, m_withLibraryButton, false);
|
||||
auto response = get_default_response();
|
||||
response.set_template(RESOURCE::templates::captured_external_html, data);
|
||||
response.set_mimeType("text/html; charset=utf-8");
|
||||
response.set_compress(true);
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
var block_path = "/catch/external";
|
||||
// called only on external links
|
||||
function capture_event(e) { e.target.setAttribute("href", encodeURI("/catch/external?source=" + e.target.href)); }
|
||||
function capture_event(e) { e.target.setAttribute("href", encodeURI(block_path + "?source=" + e.target.href)); }
|
||||
|
||||
// called on all link clicks. filters external and call capture_event
|
||||
function on_click_event(e) {
|
||||
if ("target" in e && "href" in e.target) {
|
||||
var href = e.target.href;
|
||||
if (window.location.pathname.indexOf(block_path) == 0) // already in catch page
|
||||
return;
|
||||
if (href.indexOf(window.location.origin) == 0)
|
||||
return;
|
||||
if (href.substr(0, 2) == "//")
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
<h1>External link blocked</h1>
|
||||
<p>This instance of Kiwix protects you from accidentaly going to external (out-of ZIM) links.</p>
|
||||
<p>If you intend to go to such locations, please click the link bellow.</p>
|
||||
<p>If you intend to go to such locations, please click the link below.</p>
|
||||
<p><a href="{{ source }}">Go to {{ source }}</a></p>
|
||||
<div id="kiwixfooter">
|
||||
Powered by <a href="https://kiwix.org">Kiwix</a>
|
||||
|
|
Loading…
Reference in New Issue