Skip to content

Search results don't link correctly if the url contains a "#" #14028

@andrewducker

Description

@andrewducker

Describe the bug

While the standard linking correctly encodes the url, doing a search for a file with a # in the url fails.

For example, if I have a file at src\languages\C#\csharp.md then the normal links are to src/languages/C%23/csharp.html but a search result that includes that file links to src/languages/C#/csharp.html.

How to Reproduce

Create a file with a # in the name, and something inside it that can be searched for.
Generate the docs.
Search for the text, and click the link.
Get a 404.

Environment Information

Platform:              win32; (Windows-10-10.0.26200-SP0)
Python version:        3.9.13 (tags/v3.9.13:6de2ca5, May 17 2022, 16:36:42) [MSC v.1929 64 bit (AMD64)])
Python implementation: CPython
Sphinx version:        7.4.7
Docutils version:      0.21.2
Jinja2 version:        3.1.6
Pygments version:      2.19.2

Sphinx extensions

myst_parser, sphinx_tabs.tabs

Additional context

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions