From acd4d9f2ba42baec9e538b6f16f18efe2e595286 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 27 Aug 2016 15:28:36 +0900 Subject: [PATCH] #2902: jsdump.loads fails to load search index if keywords starts with underscore --- CHANGES | 2 ++ sphinx/util/jsdump.py | 2 +- tests/test_util_jsdump.py | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 3032c95ac..b47d08966 100644 --- a/CHANGES +++ b/CHANGES @@ -7,6 +7,8 @@ Bugs fixed * #2870: flatten genindex columns' heights. * #2856: Search on generated HTML site doesnt find some symbols * #2882: Fall back to a GET request on 403 status in linkcheck +* #2902: jsdump.loads fails to load search index if keywords starts with + underscore Release 1.4.6 (released Aug 20, 2016) ===================================== diff --git a/sphinx/util/jsdump.py b/sphinx/util/jsdump.py index 43c2962f1..5a2148c5b 100644 --- a/sphinx/util/jsdump.py +++ b/sphinx/util/jsdump.py @@ -18,7 +18,7 @@ from sphinx.util.pycompat import u _str_re = re.compile(r'"(\\\\|\\"|[^"])*"') _int_re = re.compile(r'\d+') -_name_re = re.compile(r'[a-zA-Z]\w*') +_name_re = re.compile(r'[a-zA-Z_]\w*') _nameonly_re = re.compile(r'[a-zA-Z_][a-zA-Z0-9_]*$') # escape \, ", control characters and everything outside ASCII diff --git a/tests/test_util_jsdump.py b/tests/test_util_jsdump.py index 2bfeeb90e..8f98c79ac 100644 --- a/tests/test_util_jsdump.py +++ b/tests/test_util_jsdump.py @@ -14,3 +14,7 @@ def test_jsdump(): data = {u'a\xe8': 1} assert dumps(data) == '{"a\\u00e8":1}' assert data == loads(dumps(data)) + + data = {'_foo': 1} + assert dumps(data) == '{_foo:1}' + assert data == loads(dumps(data))