diff --git a/AUTHORS.rst b/AUTHORS.rst index 707c77aec04..6b244a04b92 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -108,6 +108,7 @@ Contributors * Steve Piercy -- documentation improvements * Szymon Karpinski -- intersphinx improvements * \T. Powers -- HTML output improvements +* Taiki Ohno -- bug fixes in search results * Taku Shimizu -- epub3 builder * Tamika Nomara -- bug fixes * Thomas Lamb -- linkcheck builder diff --git a/CHANGES.rst b/CHANGES.rst index f0f94fda396..fec973c7286 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -137,6 +137,8 @@ Bugs fixed * #14004: Fix :confval:`autodoc_type_aliases` when they appear in PEP 604 union syntax (``Alias | Type``). Patch by Tamika Nomara. +* #14028: Fix the encoding of URLs in search results. + Patch by Taiki Ohno. Testing diff --git a/sphinx/themes/basic/static/searchtools.js b/sphinx/themes/basic/static/searchtools.js index 5a7628a18a2..83c5fcd96b1 100644 --- a/sphinx/themes/basic/static/searchtools.js +++ b/sphinx/themes/basic/static/searchtools.js @@ -89,7 +89,8 @@ const _displayItem = (item, searchTerms, highlightTerms) => { linkUrl = docName + docLinkSuffix; } let linkEl = listItem.appendChild(document.createElement("a")); - linkEl.href = linkUrl + anchor; + const encodedLinkUrl = linkUrl.split("/").map(encodeURIComponent).join("/"); + linkEl.href = encodedLinkUrl + anchor; linkEl.dataset.score = score; linkEl.innerHTML = title; if (descr) {