diff --git a/sphinx/ext/extlinks.py b/sphinx/ext/extlinks.py index 8caba884298..6601f067773 100644 --- a/sphinx/ext/extlinks.py +++ b/sphinx/ext/extlinks.py @@ -70,7 +70,7 @@ def check_uri(self, refnode: nodes.reference) -> None: title = refnode.astext() for alias, (base_uri, _caption) in self.app.config.extlinks.items(): - uri_pattern = re.compile(base_uri.replace('%s', '(?P.+)')) + uri_pattern = re.compile(re.escape(base_uri).replace('%s', '(?P.+)')) match = uri_pattern.match(uri) if match and match.groupdict().get('value'): # build a replacement suggestion