Skip to content

Compatibility Issue with Blog Plugin in Mkdocs-Material: Encrypted Content Excerpts Exposed on Blog Index Page #84

@lnw143

Description

@lnw143

Problem Description

I am using the encryptcontent plugin to protect specific pages in my MkDocs site. The plugin works correctly when navigating to an encrypted page directly, as it prompts for a password. However, I am also using the built-in blog plugin in mkdocs-material to create a blog-style index page, and it exposes excerpts of the encrypted posts on this homepage, completely bypassing the encryption.

Steps to Reproduce

  1. Set up an MkDocs project with both mkdocs-material's built-in blog plugin and mkdocs-encryptcontent-plugin.
  2. Create a post with encryptcontent metadata (e.g., level: secret).
  3. Build the site and serve it. (mkdocs serve)
  4. Observe the blog index page (homepage). The excerpt/content from the encrypted post will be visible without any password prompt.
  5. Click the "Read more" link for that same post. You will be correctly prompted for a password, and the full content is encrypted.

Expected Behavior

Encrypted posts should not reveal their content in any form on listing pages (like the blog index) generated by other plugins. The expected behavior could be implemented in one of two ways:

  1. Preferred: The plugin should intercept the content processing for listings and replace the content of encrypted pages with a placeholder (e.g., "This post is encrypted" or a custom message).
  2. Alternative: Provide a configuration option (e.g., summary_placeholder: "This content is protected.") to allow users to define what text is shown in place of encrypted content on summary pages.

Environment

  • Python 3.13.5
  • mkdocs-encryptcontent-plugin 3.0.5
  • mkdocs 1.6.1
  • mkdocs-material 9.6.15

Configuration Example (mkdocs.yml)

theme:
  name: material
  language: 'zh'
  custom_dir: overrides
plugins:
  - search
  - encryptcontent:
      password_inventory:
      title_prefix: '[Protected]'
      summary: 'This passage is protected by password.'
      decryption_failure_message: 'Invalid user name or password.'
      password_button: True
      password_button_text: 'Enter'
      placeholder_user: 'User'
      placeholderplaceholder: 'Password'
      password_file: 'passwords.yml'
      remember_keys: false
      remember_password: false  
      threshold_warning_min_entropy: 100
      search_index: 'dynamically'
      encrypted_something:
        md-sidebar__inner: [div, class]
  - toggle-sidebar:
      toggle_button: navigation
  - blog:
      post_slugify: !!python/object/apply:pymdownx.slugs.slugify
        kwds:
          case: lower
      blog_dir: "./"
      post_url_format: "{categories}/{file}"
      post_date_format: medium
      post_url_max_categories: 1
      blog_toc: true

Thank you for developing and maintaining this essential plugin. I would be happy to provide more details or assist in testing any potential fixes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions