Skip to content

Commit

Permalink
Remote image post-transform: add a character-translation for port num…
Browse files Browse the repository at this point in the history
…ber segments.
  • Loading branch information
jayaddison committed Apr 9, 2024
1 parent 92516f8 commit 8e38511
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sphinx/transforms/post_transforms/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ def handle(self, node: nodes.image) -> None:
basename = sha1(filename.encode(), usedforsecurity=False).hexdigest() + ext
basename = CRITICAL_PATH_CHAR_RE.sub("_", basename)

dirname = node['uri'].replace(':https://', '/').translate({ord("?"): "/",
dirname = node['uri'].replace(':https://', '/').translate({ord(":"): "/",
ord("?"): "/",
ord("&"): "/"})
if len(dirname) > MAX_FILENAME_LEN:
dirname = sha1(dirname.encode(), usedforsecurity=False).hexdigest()
Expand Down

0 comments on commit 8e38511

Please sign in to comment.