Skip to content

Privacy: Invalid HTML output with customization - "="-Character is added for empty HTML-attributes preceeding the src-attribute #7625

@strobocopter

Description

@strobocopter

Context

No response

Bug description

When adding a <script>-Tag via Customization (e.g. to conditionally load scripts depending on target-environment) the material/privacy plugin can produce invalid HTML-Code.

Example:

{% extends "base.html" %}

{% block extrahead %}
{% if config.extra.add_jquery %}
<script defer src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
{% endif %}
{% endblock %}

This generates the following line in the output HTML-file:

<script defer= src="https://code.jquery.com/jquery-3.7.1.min.js"></script>

This seems to always happen if the <script>-Tag uses attributes without values (e.g. "defer" or "async") and if those attributes are placed before the "src"-attribute. In this case the plugin adds an equals-character to that attribute, but does not set a value, resulting in the browser to assume that "src= ...." is the value for the "defer"-attribute.

Related links

Reproduction

9.5.41-privacy-broken-html.zip

Steps to reproduce

See attached zip-archive...

  1. Create empty mkdocs-material project
  2. Add material/privacy plugin
  3. Add customization HTML that adds a script-Tag
  4. Have some attribute without value added to that script-Tag preceeding the src-attribute
  5. Run mkdocs build and check the created html-Files

Browser

No response

Before submitting

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue reports a bugresolvedIssue is resolved, yet unreleased if open

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions