Blame SOURCES/00344-CVE-2019-16935.patch

3d909f
diff --git a/Lib/test/test_docxmlrpc.py b/Lib/test/test_docxmlrpc.py
3d909f
index 0090333..d2adb21 100644
3d909f
--- a/Lib/test/test_docxmlrpc.py
3d909f
+++ b/Lib/test/test_docxmlrpc.py
3d909f
@@ -1,5 +1,6 @@
3d909f
 from xmlrpc.server import DocXMLRPCServer
3d909f
 import http.client
3d909f
+import re
3d909f
 import sys
3d909f
 from test import support
3d909f
 threading = support.import_module('threading')
3d909f
@@ -193,6 +194,21 @@ class DocXMLRPCHTTPGETServer(unittest.TestCase):
3d909f
              b'method_annotation(x: bytes)'),
3d909f
             response.read())
3d909f
 
3d909f
+    def test_server_title_escape(self):
3d909f
+        # bpo-38243: Ensure that the server title and documentation
3d909f
+        # are escaped for HTML.
3d909f
+        self.serv.set_server_title('test_title<script>')
3d909f
+        self.serv.set_server_documentation('test_documentation<script>')
3d909f
+        self.assertEqual('test_title<script>', self.serv.server_title)
3d909f
+        self.assertEqual('test_documentation<script>',
3d909f
+                self.serv.server_documentation)
3d909f
+
3d909f
+        generated = self.serv.generate_html_documentation()
3d909f
+        title = re.search(r'<title>(.+?)</title>', generated).group()
3d909f
+        documentation = re.search(r'

<tt>(.+?)</tt>

', generated).group()
3d909f
+        self.assertEqual('<title>Python: test_title<script></title>', title)
3d909f
+        self.assertEqual('

<tt>test_documentation<script></tt>

', documentation)
3d909f
+
3d909f
 
3d909f
 if __name__ == '__main__':
3d909f
     unittest.main()
3d909f
diff --git a/Lib/xmlrpc/server.py b/Lib/xmlrpc/server.py
3d909f
index 3e0dca0..efe5937 100644
3d909f
--- a/Lib/xmlrpc/server.py
3d909f
+++ b/Lib/xmlrpc/server.py
3d909f
@@ -106,6 +106,7 @@ server.handle_request()
3d909f
 
3d909f
 from xmlrpc.client import Fault, dumps, loads, gzip_encode, gzip_decode
3d909f
 from http.server import BaseHTTPRequestHandler
3d909f
+import html
3d909f
 import http.server
3d909f
 import socketserver
3d909f
 import sys
3d909f
@@ -904,7 +905,7 @@ class XMLRPCDocGenerator:
3d909f
                                 methods
3d909f
                             )
3d909f
 
3d909f
-        return documenter.page(self.server_title, documentation)
3d909f
+        return documenter.page(html.escape(self.server_title), documentation)
3d909f
 
3d909f
 class DocXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
3d909f
     """XML-RPC and documentation request handler class.