diff --git a/sphinx/writers/html.py b/sphinx/writers/html.py index 34b73a0a5c3..e0f10862e8a 100644 --- a/sphinx/writers/html.py +++ b/sphinx/writers/html.py @@ -612,7 +612,7 @@ def visit_image(self, node: Element) -> None: # rewrite the URI if the environment knows about it if olduri in self.builder.images: node['uri'] = posixpath.join(self.builder.imgpath, - self.builder.images[olduri]) + urllib.parse.quote(self.builder.images[olduri])) if 'scale' in node: # Try to figure out image height and width. Docutils does that too, diff --git a/sphinx/writers/html5.py b/sphinx/writers/html5.py index b9d0f648c94..d94596955ab 100644 --- a/sphinx/writers/html5.py +++ b/sphinx/writers/html5.py @@ -560,7 +560,7 @@ def visit_image(self, node: Element) -> None: # rewrite the URI if the environment knows about it if olduri in self.builder.images: node['uri'] = posixpath.join(self.builder.imgpath, - self.builder.images[olduri]) + urllib.parse.quote(self.builder.images[olduri])) if 'scale' in node: # Try to figure out image height and width. Docutils does that too,