diff --git a/CHANGES b/CHANGES index c75929ca6a3..4e5f7b29855 100644 --- a/CHANGES +++ b/CHANGES @@ -120,6 +120,8 @@ Deprecated Features added -------------- +* #8959: using UNIX path separator in image directive confuses Sphinx on Windows + Bugs fixed ---------- diff --git a/sphinx/environment/__init__.py b/sphinx/environment/__init__.py index 60ede8188a4..9218e40c4d2 100644 --- a/sphinx/environment/__init__.py +++ b/sphinx/environment/__init__.py @@ -34,6 +34,7 @@ from sphinx.util.docutils import LoggingReporter from sphinx.util.i18n import CatalogRepository, docname_to_domain from sphinx.util.nodes import is_translatable +from sphinx.util.osutil import canon_path, os_path if TYPE_CHECKING: from sphinx.application import Sphinx @@ -335,6 +336,7 @@ def relfn2path(self, filename: str, docname: str = None) -> Tuple[str, str]: source dir, while relative filenames are relative to the dir of the containing document. """ + filename = os_path(filename) if filename.startswith('/') or filename.startswith(os.sep): rel_fn = filename[1:] else: @@ -342,7 +344,7 @@ def relfn2path(self, filename: str, docname: str = None) -> Tuple[str, str]: base=None)) rel_fn = path.join(docdir, filename) - return (posixpath.normpath(rel_fn), + return (canon_path(path.normpath(rel_fn)), path.normpath(path.join(self.srcdir, rel_fn))) @property