mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-38243, xmlrpc.server: Escape the server_title (GH-16373)
Escape the server title of xmlrpc.server.DocXMLRPCServer when rendering the document page as HTML.
This commit is contained in:
parent
dd6117c6d7
commit
e8650a4f8c
3 changed files with 21 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
|||
from xmlrpc.server import DocXMLRPCServer
|
||||
import http.client
|
||||
import re
|
||||
import sys
|
||||
import threading
|
||||
import unittest
|
||||
|
@ -192,6 +193,21 @@ class DocXMLRPCHTTPGETServer(unittest.TestCase):
|
|||
b'method_annotation</strong></a>(x: bytes)</dt></dl>'),
|
||||
response.read())
|
||||
|
||||
def test_server_title_escape(self):
|
||||
# bpo-38243: Ensure that the server title and documentation
|
||||
# are escaped for HTML.
|
||||
self.serv.set_server_title('test_title<script>')
|
||||
self.serv.set_server_documentation('test_documentation<script>')
|
||||
self.assertEqual('test_title<script>', self.serv.server_title)
|
||||
self.assertEqual('test_documentation<script>',
|
||||
self.serv.server_documentation)
|
||||
|
||||
generated = self.serv.generate_html_documentation()
|
||||
title = re.search(r'<title>(.+?)</title>', generated).group()
|
||||
documentation = re.search(r'<p><tt>(.+?)</tt></p>', generated).group()
|
||||
self.assertEqual('<title>Python: test_title<script></title>', title)
|
||||
self.assertEqual('<p><tt>test_documentation<script></tt></p>', documentation)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue