File fix-keyword-escaping.patch of Package python-Sphinx.15532

From 866157b51443d59aaaff0efcce70bef82a448dad Mon Sep 17 00:00:00 2001
From: Takeshi KOMIYA <i.tkomiya@gmail.com>
Date: Sun, 24 Feb 2019 18:25:51 +0900
Subject: [PATCH 1/2] Fix #6097: the keyword IDs are not escaped qthelp in .qhp
 file

Backported to Sphinx 1.7.6 by fvogt@suse.com
---

Index: Sphinx-1.7.6/tests/roots/test-need-escaped/index.rst
===================================================================
--- Sphinx-1.7.6.orig/tests/roots/test-need-escaped/index.rst
+++ Sphinx-1.7.6/tests/roots/test-need-escaped/index.rst
@@ -21,6 +21,12 @@ Contents:
 
 .. index::
    pair: "subsection"; <subsection>
+   single: & (ampersand)
+   single: < (less)
+   single: > (greater)
+   single: Sphinx (document generator)
+   single: keyword1 (class in ID)
+   single: keyword2 (foo bar baz)
 
 ----------
 subsection
Index: Sphinx-1.7.6/sphinx/builders/qthelp.py
===================================================================
--- Sphinx-1.7.6.orig/sphinx/builders/qthelp.py
+++ Sphinx-1.7.6/sphinx/builders/qthelp.py
@@ -9,6 +9,7 @@
     :license: BSD, see LICENSE for details.
 """
 
+import html
 import codecs
 import os
 import posixpath
@@ -220,7 +221,7 @@ class QtHelpBuilder(StandaloneHTMLBuilde
             # descr = groupdict.get('descr')
             if shortname.endswith('()'):
                 shortname = shortname[:-2]
-            id = '%s.%s' % (id, shortname)
+            id = html.escape('%s.%s' % (id, shortname), True)
         else:
             id = None
 
Index: Sphinx-1.7.6/tests/test_build_qthelp.py
===================================================================
--- Sphinx-1.7.6.orig/tests/test_build_qthelp.py
+++ Sphinx-1.7.6/tests/test_build_qthelp.py
@@ -66,10 +66,26 @@ def test_qthelp_escaped(app, status, war
     assert toc[0][3].attrib == {'title': 'baz', 'ref': 'baz.html'}
 
     keywords = et.find('.//keywords')
-    assert len(keywords) == 2
-    assert keywords[0].attrib == {'name': '<subsection>', 'ref': 'index.html#index-0'}
-    assert keywords[1].attrib == {'name': '"subsection"', 'ref': 'index.html#index-0'}
-
+    assert len(keywords) == 8
+    assert keywords[1].attrib == {'name': '& (ampersand)',
+                                  'id': 'ampersand.&',
+                                  'ref': 'index.html#index-0'}
+    assert keywords[2].attrib == {'name': '< (less)',
+                                  'id': 'less.<',
+                                  'ref': 'index.html#index-0'}
+    assert keywords[3].attrib == {'name': '"subsection"',
+                                  'ref': 'index.html#index-0'}
+    assert keywords[4].attrib == {'name': '> (greater)',
+                                  'id': 'greater.>',
+                                  'ref': 'index.html#index-0'}
+    assert keywords[5].attrib == {'name': 'keyword1 (class in ID)',
+                                  'id': 'ID.keyword1',
+                                  'ref': 'index.html#index-0'}
+    assert keywords[6].attrib == {'name': 'keyword2 (foo bar baz)',
+                                  'ref': 'index.html#index-0'}
+    assert keywords[7].attrib == {'name': 'Sphinx (document generator)',
+                                  'id': 'document.Sphinx',
+                                  'ref': 'index.html#index-0'}
 
 @pytest.mark.sphinx('qthelp', testroot='basic')
 def test_qthelp_namespace(app, status, warning):
openSUSE Build Service is sponsored by