From 175301218d4c6cdac2c5b9c8e39eb670ec52a81d Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 24 Jul 2021 21:53:57 +0900 Subject: [PATCH] Fix #9456: html search: abbreation marks are inserted to the search --- CHANGES | 2 ++ sphinx/themes/basic/static/searchtools.js | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 42b47a7dbb6..31c755cc45f 100644 --- a/CHANGES +++ b/CHANGES @@ -21,6 +21,8 @@ Bugs fixed ---------- * #9487: autodoc: typehint for cached_property is not shown +* #9456: html search: abbreation marks are inserted to the search result if + failed to fetch the content of the page Testing -------- diff --git a/sphinx/themes/basic/static/searchtools.js b/sphinx/themes/basic/static/searchtools.js index 8eb14218b5a..882e9a7c618 100644 --- a/sphinx/themes/basic/static/searchtools.js +++ b/sphinx/themes/basic/static/searchtools.js @@ -282,7 +282,10 @@ var Search = { complete: function(jqxhr, textstatus) { var data = jqxhr.responseText; if (data !== '' && data !== undefined) { - listItem.append(Search.makeSearchSummary(data, searchterms, hlterms)); + var summary = Search.makeSearchSummary(data, searchterms, hlterms); + if (summary) { + listItem.append(summary); + } } Search.output.append(listItem); setTimeout(function() { @@ -492,6 +495,9 @@ var Search = { */ makeSearchSummary : function(htmlText, keywords, hlwords) { var text = Search.htmlToText(htmlText); + if (text == "") { + return null; + } var textLower = text.toLowerCase(); var start = 0; $.each(keywords, function() {