Skip to content

Commit

Permalink
Fix sphinx-doc#8959: using UNIX path separator confuses Sphinx on Win…
Browse files Browse the repository at this point in the history
…dows
  • Loading branch information
tk0miya committed Mar 6, 2021
1 parent 0c76c1a commit c8125a9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES
Expand Up @@ -120,6 +120,8 @@ Deprecated
Features added
--------------

* #8959: using UNIX path separator in image directive confuses Sphinx on Windows

Bugs fixed
----------

Expand Down
4 changes: 3 additions & 1 deletion sphinx/environment/__init__.py
Expand Up @@ -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
Expand Down Expand Up @@ -335,14 +336,15 @@ 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:
docdir = path.dirname(self.doc2path(docname or self.docname,
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
Expand Down

0 comments on commit c8125a9

Please sign in to comment.