Skip to content

Commit

Permalink
escape base_uri in extlinks to avoid regex issues with URIs containin…
Browse files Browse the repository at this point in the history
…g special characters
  • Loading branch information
nicoa committed Mar 13, 2022
1 parent 5a8ce35 commit 554f589
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion sphinx/ext/extlinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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<value>.+)'))
uri_pattern = re.compile(re.escape(base_uri).replace('%s', '(?P<value>.+)'))
match = uri_pattern.match(uri)
if match and match.groupdict().get('value'):
# build a replacement suggestion
Expand Down

0 comments on commit 554f589

Please # to comment.