Skip to content

regex failing on check of hardcoded links #10205

@nicoa

Description

@nicoa

Describe the bug

#9800 (contained in release 4.4.0) introduced an issue on our side for extlinks that contain special characters.

the problematic part of code is re.compile(s.replace("%s", "(?P<value>.+)")). a possible fix is re.compile(re.escape(s).replace("%s", "(?P<value>.+)")).

Would you be happy to receive a PR on this?

How to Reproduce

use:

extlinks = {
    "package": (
        r"https://gitlab.com/path_to_my_project/-/packages?search[]=%s",
        "package %s",
    ),
}

this will lead to re.error: unterminated character set at position 88 when any link is found on the parsed page.

Expected behavior

No response

Your project

sorry, nothing I can share - let me know if a reproducing example is required

Screenshots

No response

OS

Unix, Mac

Python version

3.9

Sphinx version

4.4.0

Sphinx extensions

extlinks

Extra tools

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions