unverbuggt / mkdocs-encryptcontent-plugin

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

Can't make it work using python 3.10.4 in local testing #25

Closed Mara-Li closed 2 years ago

Mara-Li commented 2 years ago

Hello! I try this plugin, but can't make it work using mkdocs serve in a local testing with :

My configuration :

plugins:
  - search: 
  - git-revision-date-localized:
      type: date
      fallback_to_build_date: true
      locale: fr
  - ezlinks:
        wikilinks: true
  - mermaid2
  - awesome-pages
  - tooltipster-links
  - embed_file
  - tags:
      tags_file: tags.md
  - encryptcontent:
      title_prefix: '🔐'
      summary: 'Page privée'
      placeholder: 'Mot de passe'
      decryption_failure_message: 'Mot de passe invalide !'
      encryption_info_message: "Vous n'avez pas accès à cette page"
      search_index: 'encrypted'
      password_button: True
      password_button_text: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" height="1em" width="1em"><!--! Font Awesome Pro 6.1.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. --><path d="M416 32h-64c-17.67 0-32 14.33-32 32s14.33 32 32 32h64c17.67 0 32 14.33 32 32v256c0 17.67-14.33 32-32 32h-64c-17.67 0-32 14.33-32 32s14.33 32 32 32h64c53.02 0 96-42.98 96-96V128C512 74.98 469 32 416 32zM342.6 233.4l-128-128c-12.51-12.51-32.76-12.49-45.25 0c-12.5 12.5-12.5 32.75 0 45.25L242.8 224H32C14.31 224 0 238.3 0 256s14.31 32 32 32h210.8l-73.38 73.38c-12.5 12.5-12.5 32.75 0 45.25s32.75 12.5 45.25 0l128-128C355.1 266.1 355.1 245.9 342.6 233.4z"/></svg>'

My testing file :

---
password: pass
---
testing contents

I copy/pass the password and the page keeps sending me invalid password.

CoinK0in commented 2 years ago

Hi,

I answer late because I had not found the time to really do tests with your versions etc .. Sorry.

At first sight, it seems to me, that the problem is related to your plugin "embed_file". Let me explain. After installing your environment (same version), everything seems to work (in python 3.10.4) if I comment the following line in your configuration: - embed_file.

The first impacting thing that I identified is a modification of the encrypt string created by mkdocs-encruptycontent-plugins. As you can see in these two captures, when your plugins is activated, some spaces are added before and after the encrypted string. If you remove these spaces from the string, the encryption/decryption works as expected. Without activating your plugin: without

With the activation of your plugin: with

Unfortunately, I don't have the detailed technical explanation of what is happening and why. I will have to study your code more and add some debug to find it.

Could you already validate the operation of my plugin in version 3.10.4 WITHOUT your plugins ? No problem for me once removed.

CoinK0in commented 2 years ago

The problem comes more exactly from the use of the "prettify()" function in this part of your code which as described in the BS4 documentation here, adds whitespace (in the form of newlines).

Mara-Li commented 2 years ago

THank your for this report, I will take a look !

Mara-Li commented 2 years ago

Thanks, I could found the two culprit!