Fix #2019: the domain objects in search result are not escaped

This commit is contained in:
Takeshi KOMIYA 2016-02-29 10:52:15 +09:00
parent 2cd696eea5
commit 77df787e81
3 changed files with 16 additions and 1 deletions

View File

@ -22,7 +22,7 @@ Bugs fixed
* #2324: Print a hint how to increase the recursion limit when it is hit.
* #1565, #2229: Revert new warning; the new warning will be triggered from version 1.4 on.
* #2329: Refresh environment forcely if source directory has changed.
* #2019: Fix the domain objects in search result are not escaped
Release 1.3.5 (released Jan 24, 2016)
=====================================

View File

@ -16,6 +16,7 @@ from docutils.nodes import raw, comment, title, Text, NodeVisitor, SkipNode
from os import path
from sphinx.util import jsdump, rpartition
from sphinx.util.pycompat import htmlescape
class SearchLanguage(object):
@ -283,6 +284,7 @@ class IndexBuilder(object):
continue
if prio < 0:
continue
fullname = htmlescape(fullname)
prefix, name = rpartition(fullname, '.')
pdict = rv.setdefault(prefix, {})
try:

View File

@ -13,6 +13,9 @@ from docutils import frontend, utils
from docutils.parsers import rst
from sphinx.search import IndexBuilder
from sphinx.util import jsdump
from util import with_app
settings = parser = None
@ -39,3 +42,13 @@ def test_wordcollector():
ix.feed('filename', 'title', doc)
assert 'boson' not in ix._mapping
assert 'fermion' in ix._mapping
@with_app()
def test_objects_are_escaped(app, status, warning):
app.builder.build_all()
searchindex = (app.outdir / 'searchindex.js').text()
assert searchindex.startswith('Search.setIndex(')
index = jsdump.loads(searchindex[16:-2])
assert 'n::Array&lt;T, d&gt;' in index.get('objects').get('') # n::Array<T,d> is escaped