From 83eba7e269cebaf430a6f7a812a0eec7e95b59f7 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Mon, 13 Jul 2020 21:56:28 +0900 Subject: [PATCH] Fix #7745: html: inventory is broken if the docname contains a space The format of inventory file expects that URIs do not contain spaces. Not to generate a URL containing spaces, HTMLBuilder.get_target_uri() should do URL-escaping to the docname. --- CHANGES | 1 + sphinx/builders/html/__init__.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 027a4c342cf..55e70a86f17 100644 --- a/CHANGES +++ b/CHANGES @@ -19,6 +19,7 @@ Features added * #7888: napoleon: Add aliases Warn and Raise. * C, added :rst:dir:`c:alias` directive for inserting copies of existing declarations. +* #7745: html: inventory is broken if the docname contains a space * #7902: html theme: Add a new option :confval:`globaltoc_maxdepth` to control the behavior of globaltoc in sidebar * #7052: add ``:noindexentry:`` to the Python, C, C++, and Javascript domains. diff --git a/sphinx/builders/html/__init__.py b/sphinx/builders/html/__init__.py index 69349549e0c..923212a9948 100644 --- a/sphinx/builders/html/__init__.py +++ b/sphinx/builders/html/__init__.py @@ -15,6 +15,7 @@ import warnings from os import path from typing import Any, Dict, IO, Iterable, Iterator, List, Set, Tuple +from urllib.parse import quote from docutils import nodes from docutils.core import publish_parts @@ -947,7 +948,7 @@ def has_wildcard(pattern: str) -> bool: # --------- these are overwritten by the serialization builder def get_target_uri(self, docname: str, typ: str = None) -> str: - return docname + self.link_suffix + return quote(docname) + self.link_suffix def handle_page(self, pagename: str, addctx: Dict, templatename: str = 'page.html', outfilename: str = None, event_arg: Any = None) -> None: