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

HTML character entities (&, <, etc.) appear in search result titles #1012

Closed
atmarx opened this issue Feb 27, 2019 · 4 comments

Comments

@atmarx
Copy link

commented Feb 27, 2019

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.

@squidfunk

This comment has been minimized.

Copy link
Owner

commented Mar 1, 2019

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

@squidfunk squidfunk added the bug label Mar 1, 2019

@squidfunk squidfunk changed the title & appears in search results HTML character entities (&, <, etc.) appear in search result titles Mar 1, 2019

@squidfunk

This comment has been minimized.

Copy link
Owner

commented Mar 1, 2019

Fixed in 8a01e0c. 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.

@squidfunk

This comment has been minimized.

Copy link
Owner

commented Mar 1, 2019

4.0.2 was just released.

@squidfunk squidfunk closed this Mar 1, 2019

@atmarx

This comment has been minimized.

Copy link
Author

commented Mar 3, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.