libkiwix/include
renaud gaudin 0ad8bf45fc Add external links blocking in serve
In many use cases, it is not wanted to have user accidentaly click on external links
and leave the served ZIM content.
This could be because the result is unpredictible (reader not implementing this properly)
or because the serve user knows there's no backup internet connexion or because there is
an induced cost behind external links that doesn't affect served content.

using a new flag (`blockExternalLinks`) on `Response`/`setTaskBar`, a piece of JS code
is injected into the taskbar code.
This code adds a JS handler on all link click events and verifies the destination.
If the destination appears to be an external link (1), the link target is changed to
a specific URL:

```
/external?source=<original_uri>
```

(1) external is a link that's not on the same origin and starts with either `http:` `https:` or `//`.

Server implements a new handler on `/external` that displays a new page (`captured_external.html`)
which returns a generic message explaining the situation and offering to click on the link
again should the user really want to.
This is done by specifically asking `set_taskbar` to not block external requests on that page.

This approach allows integrators using a reverse proxy to handle that endpoint differently (rebrand it)

1. `Server` now has an `m_blockExternalLinks` defaulting to `false`
1. `Server.setTaskbar` is extended to support an additional bool to set the variable.
1. `Response` now has an `m_blockExternalLinks`
1. `Response` constr expects an additional bool for `blockExternalLinks`.
1. `Response.set_taskbar` is extended to support an additional bool to set the variable.
1. JNI/Java Wrapper reflects the extensions.
1. New resource file `templates/block_external.js` (included in head_part). Should it be in skin?
1. New resource file `templates/captured_external.html` for `handle_captured_external()`
1. Added a comment on `head_part.html` to help with JS insertion at the right place
1. `introduce_taskbar()` conditionnaly inserts the JS inside the taskbar
2020-03-26 12:06:36 +00:00
..
tools Move function to convert and use tags inside otherTools. 2020-01-30 17:48:56 +01:00
book.h Add flavour attribute to book. 2020-01-30 17:48:56 +01:00
bookmark.h Add bookmarks support. 2018-12-02 15:47:29 +01:00
common.h Allow us to declare method to be deprecated. 2018-04-19 18:04:07 +02:00
downloader.h Include stdexcept to fix GCC v10 compilation 2020-02-01 13:52:27 +01:00
entry.h Remove trailing spaces 2019-12-08 11:52:16 +01:00
kiwix.h Format all the code using clang-format. 2017-07-05 15:22:34 +02:00
kiwixserve.h add setPort() method 2019-10-28 15:56:49 +01:00
library.h Add the method get bookByPath in library. 2020-03-06 12:08:05 +01:00
libxml_dumper.h Add bookmarks support. 2018-12-02 15:47:29 +01:00
manager.h Trust the library.xml information by default. 2020-01-30 18:22:07 +01:00
meson.build Introduce the server functionality in the kiwix-lib. 2019-08-11 11:30:43 +02:00
name_mapper.h Add a name_mapper mapping the HumanReadable name to the id. 2019-08-11 11:30:43 +02:00
opds_dumper.h [API break] Move all the tools in the tools directory instead of common. 2019-01-23 15:31:38 +01:00
reader.h Add a method to get the value of a specific tag. 2019-09-17 10:37:53 +02:00
search_renderer.h Move the search html renderer in a different class than the searcher. 2019-08-11 10:19:48 +02:00
searcher.h Make the search argument constant. 2020-03-06 12:08:05 +01:00
server.h Add external links blocking in serve 2020-03-26 12:06:36 +00:00