|
|
f8e6ca |
diff --git a/Lib/test/test_docxmlrpc.py b/Lib/test/test_docxmlrpc.py
|
|
|
f8e6ca |
index 0090333..d2adb21 100644
|
|
|
f8e6ca |
--- a/Lib/test/test_docxmlrpc.py
|
|
|
f8e6ca |
+++ b/Lib/test/test_docxmlrpc.py
|
|
|
f8e6ca |
@@ -1,5 +1,6 @@
|
|
|
f8e6ca |
from xmlrpc.server import DocXMLRPCServer
|
|
|
f8e6ca |
import http.client
|
|
|
f8e6ca |
+import re
|
|
|
f8e6ca |
import sys
|
|
|
f8e6ca |
from test import support
|
|
|
f8e6ca |
threading = support.import_module('threading')
|
|
|
f8e6ca |
@@ -193,6 +194,21 @@ class DocXMLRPCHTTPGETServer(unittest.TestCase):
|
|
|
f8e6ca |
b'method_annotation(x: bytes)'),
|
|
|
f8e6ca |
response.read())
|
|
|
f8e6ca |
|
|
|
f8e6ca |
+ def test_server_title_escape(self):
|
|
|
f8e6ca |
+ # bpo-38243: Ensure that the server title and documentation
|
|
|
f8e6ca |
+ # are escaped for HTML.
|
|
|
f8e6ca |
+ self.serv.set_server_title('test_title<script>')
|
|
|
f8e6ca |
+ self.serv.set_server_documentation('test_documentation<script>')
|
|
|
f8e6ca |
+ self.assertEqual('test_title<script>', self.serv.server_title)
|
|
|
f8e6ca |
+ self.assertEqual('test_documentation<script>',
|
|
|
f8e6ca |
+ self.serv.server_documentation)
|
|
|
f8e6ca |
+
|
|
|
f8e6ca |
+ generated = self.serv.generate_html_documentation()
|
|
|
f8e6ca |
+ title = re.search(r'<title>(.+?)</title>', generated).group()
|
|
|
f8e6ca |
+ documentation = re.search(r'<tt>(.+?)</tt> ', generated).group()
|
|
|
f8e6ca |
+ self.assertEqual('<title>Python: test_title<script></title>', title)
|
|
|
f8e6ca |
+ self.assertEqual('<tt>test_documentation<script></tt> ', documentation)
|
|
|
f8e6ca |
+
|
|
|
f8e6ca |
|
|
|
f8e6ca |
if __name__ == '__main__':
|
|
|
f8e6ca |
unittest.main()
|
|
|
f8e6ca |
diff --git a/Lib/xmlrpc/server.py b/Lib/xmlrpc/server.py
|
|
|
f8e6ca |
index 3e0dca0..efe5937 100644
|
|
|
f8e6ca |
--- a/Lib/xmlrpc/server.py
|
|
|
f8e6ca |
+++ b/Lib/xmlrpc/server.py
|
|
|
f8e6ca |
@@ -106,6 +106,7 @@ server.handle_request()
|
|
|
f8e6ca |
|
|
|
f8e6ca |
from xmlrpc.client import Fault, dumps, loads, gzip_encode, gzip_decode
|
|
|
f8e6ca |
from http.server import BaseHTTPRequestHandler
|
|
|
f8e6ca |
+import html
|
|
|
f8e6ca |
import http.server
|
|
|
f8e6ca |
import socketserver
|
|
|
f8e6ca |
import sys
|
|
|
f8e6ca |
@@ -904,7 +905,7 @@ class XMLRPCDocGenerator:
|
|
|
f8e6ca |
methods
|
|
|
f8e6ca |
)
|
|
|
f8e6ca |
|
|
|
f8e6ca |
- return documenter.page(self.server_title, documentation)
|
|
|
f8e6ca |
+ return documenter.page(html.escape(self.server_title), documentation)
|
|
|
f8e6ca |
|
|
|
f8e6ca |
class DocXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
|
|
f8e6ca |
"""XML-RPC and documentation request handler class.
|