unverbuggt / mkdocs-encryptcontent-plugin

A MkDocs plugin that encrypt/decrypt markdown content with AES
https://unverbuggt.github.io/mkdocs-encryptcontent-plugin/
MIT License
123 stars 15 forks source link

fix some problems with search index encryption #35

Closed unverbuggt closed 1 year ago

unverbuggt commented 1 year ago

Hi,

even though the default setting when "encryptcontent" and "search" is enabled (search_index: 'encrypted') behaves as described

encrypted : Search index is encrypted on build. Search is not possible on all encrypted pages.

i think it is a bit anoying that search results of encrypted pages show up (encrypted) because the search term is included in the heading or title (third patch fixes this). And thus removing all encrypted pages from the search index seems better with this mode.

I know it's an experimental feature, but at first the search_index: 'dynamically' didn't work at all in my environment (Windows - first patch).

The second problem i encountered (second patch) was that the search index contains 'location' relative to the site root, but in my case window.location.pathname would additionally contain a path different from / (root). To clarify:

site_url: https://example.com/foo/          # defined in mkdocs.yml
page_url: https://example.com/foo/bar/      # page in docs/bar.md

now this happens in javascript: window.location.pathname = /foo/bar/\ but the search index contains a location = bar/ so it is never decrypted when decrypt_search is called.

The last part that I wanted to fix is the leaking of additional information about the encrypted pages, namely the titles of all headings and anchors of the encrypted pages (fourth patch).

CoinK0in commented 1 year ago

I back to check your changes but I still don't have the time to fully validate. And it's seems to have a problem during the build when I incorporate your changes. I have to find the time to do some fix. Sorry for the delay.

By the way, would you like to take over the management of this plugin? I no longer have the time and the motivation to correct the problems and improve the plugin . . .