Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic search decryption in mkdocs-material #52

Closed
ttran2 opened this issue Sep 14, 2023 · 6 comments
Closed

Dynamic search decryption in mkdocs-material #52

ttran2 opened this issue Sep 14, 2023 · 6 comments
Labels
wontfix This will not be worked on

Comments

@ttran2
Copy link

ttran2 commented Sep 14, 2023

I have set a global_password and used encrypted_something to hide the nav-bar (md-nav), tabs (md-tabs), and search-box (md-search). However, when providing the password and decrypting the page, only the nav-bar and tabs became visible, while the search-box was still hidden.

Here is a snippet from my mkdocs.yml

plugins:
  - search:
      indexing: 'full'
  - encryptcontent:
      search_index: 'clear'
      global_password: 'somepassword'
      encrypted_something:
        md-nav: [nav, class]
        md-tabs: [nav, class]
        md-search: [div, class]

PS. Yes, I am aware that setting the search_index to clear mode can make it possible to get the data by digging up the search indexes, however, downgrading the mkdocs-material to below 9.x.x (and then patching it) is too big of a drawback, and disabling search feature is also a huge drawback.

@unverbuggt
Copy link
Owner

Hi,

I've tested this and conclude that 'md-search' div is in fact correctly decrypted.
However, normally there are events attached to 'md-search', 'md-search__form' and 'md-search__input' and these events won't magically be attached after decryption. One could try to figure out how to reattach these in a reload_js script, but one might as well fix the dynamical search decryption for material.

The dynamical search decryption for material-theme is a thing I need for a project of ours, so this will hopefully be taken care of some time(TM). But it is not high priority, as the workaround with material 8 exists.
If anyone can help with this, it is highly appreciated.

While testing, I also found that the current material breaks other stuff as well, so thank you for bringing this up.

@unverbuggt unverbuggt added the wontfix This will not be worked on label Sep 15, 2023
@unverbuggt
Copy link
Owner

...I found a way to hack into material 9 that allows modifying the search index.
But it is still only a hack, that exchanges the request to the "search_index.json" file by the modified search index in sessionStorage.

There is hope that material might cache the search index some day, where we could modify it by this plugin. Until then, patching is the not-so-bright-but-only solution I could come up with.

mkdocs_material-9.3.2-py3-none-any (patched encryptcontent-index).zip

@ttran2
Copy link
Author

ttran2 commented Sep 19, 2023

Hi, thank you very much for the help and the patch, though I myself also ended up patching mkdocs-material myself, in order for it to fetch the search index from the sessionStorage 😅
https://github.com/ttran2/mkdocs-material/tree/support-decryption

@W1ndys

This comment was marked as off-topic.

@unverbuggt

This comment was marked as off-topic.

@W1ndys

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants