Mkdocs-material: HTML character entities (&, <, etc.) appear in search result titles

Created on 27 Feb 2019  路  4Comments  路  Source: squidfunk/mkdocs-material

## Description

For any page or section titles with ampersands in them, they appear in the search results as &.

Expected behavior

I would expect it to be rendered as the ampersand character.

Workaround

I edited the local application.{version}.js to append .replace('&', '&') after r.title and e.title in the area I found searching for md-search-result. There may be a better place to handle this replacement, but I was able to get it to render the search results as expected with this addition.

bug fix available

Most helpful comment

Much appreciated! Thanks for continuing to release such a useful project.

All 4 comments

Confirmed. Thanks for reporting! Funny that this didn't occur to somebody until now. Should be fixable quite easily.

Fixed in 8a01e0cc8c22b4ccae4a9fd90f29596d36e48317. The problem was introduced when we mitigated JavaScript code snippet execution from code snippets (when shown in the search results) by escaping the document's HTML in the search results. This was also done for page and section titles which are already escaped by MkDocs leading to double-escaping, e.g. &amp.

I'm preparing 4.0.2 which will include the fix.

4.0.2 was just released.

Much appreciated! Thanks for continuing to release such a useful project.

Was this page helpful?
0 / 5 - 0 ratings