diff --git a/sphinx/ext/intersphinx.py b/sphinx/ext/intersphinx.py index 7a1aeb401..9551e3cd1 100644 --- a/sphinx/ext/intersphinx.py +++ b/sphinx/ext/intersphinx.py @@ -30,6 +30,7 @@ import codecs import urllib2 import posixpath from os import path +import re from docutils import nodes @@ -99,7 +100,12 @@ def read_inventory_v2(f, uri, join, bufsize=16*1024): assert not buf for line in split_lines(read_chunks()): - name, type, prio, location, dispname = line.rstrip().split(None, 4) + # be careful to handle names with embedded spaces correctly + m = re.match(r'(?x)(.+?)\s+(\S*:\S*)\s+(\S+)\s+(\S+)\s+(.*)', + line.rstrip()) + if not m: + continue + name, type, prio, location, dispname = m.groups() if location.endswith(u'$'): location = location[:-1] + name location = join(uri, location) diff --git a/tests/test_intersphinx.py b/tests/test_intersphinx.py index e1f4e827f..55320eaec 100644 --- a/tests/test_intersphinx.py +++ b/tests/test_intersphinx.py @@ -43,6 +43,7 @@ module1 py:module 0 foo.html#module-module1 Long Module desc module2 py:module 0 foo.html#module-$ - module1.func py:function 1 sub/foo.html#$ - CFunc c:function 2 cfunc.html#CFunc - +a term std:term -1 glossary.html#term-a-term - '''.encode('utf-8')) @@ -76,6 +77,8 @@ def test_read_inventory_v2(): assert invdata1['py:function']['module1.func'][2] == \ '/util/sub/foo.html#module1.func' assert invdata1['c:function']['CFunc'][2] == '/util/cfunc.html#CFunc' + assert invdata1['std:term']['a term'][2] == \ + '/util/glossary.html#term-a-term' @with_app(confoverrides={'extensions': 'sphinx.ext.intersphinx'})