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

Search highlighting does not properly escape HTML #2879

Closed
5 tasks done
jbms opened this issue Jul 28, 2021 · 2 comments
Closed
5 tasks done

Search highlighting does not properly escape HTML #2879

jbms opened this issue Jul 28, 2021 · 2 comments
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open

Comments

@jbms
Copy link
Contributor

jbms commented Jul 28, 2021

Contribution guidelines

I've found a bug and checked that ...

  • ... the problem doesn't occur with the mkdocs or readthedocs themes
  • ... the problem persists when all overrides are removed, i.e. custom_dir, extra_javascript and extra_css
  • ... the documentation does not mention anything about my problem
  • ... there are no open or closed issues that are related to my problem

Description

Search highlighting obtains the textContent of nodes, applies replacements, and then adds it back as innerHTML.

Consequently, text that looks like HTML tags can get mangled.

Instead, escapeHTML(value) should be used prior to applying the replacements in src/assets/javascripts/integrations/search/highlighter/index.ts.

Example link:

https://squidfunk.github.io/mkdocs-material/customization/?h=your#additional-variables

Note that the the <!-- Add your additional information here --> text disappears when we add the ?h=your parameter.

Expected behaviour

n/a

Actual behaviour

n/a

Steps to reproduce

n/a

Package versions

mkdocs-material master as of 2021-07-28:

e29dfd0

Configuration

n/a

System information

n/a

@squidfunk
Copy link
Owner

Good catch! Fixed in 6744eb6.

@squidfunk squidfunk added bug Issue reports a bug resolved Issue is resolved, yet unreleased if open labels Jul 28, 2021
@squidfunk
Copy link
Owner

Released as part of 7.2.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open
Projects
None yet
Development

No branches or pull requests

2 participants