8000 Issue #22421 - Secure pydoc server run. Bind it to localhost instead … · python/cpython@0840b41 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0840b41

Browse files
committed
Issue #22421 - Secure pydoc server run. Bind it to localhost instead of all interfaces.
1 parent dad182c commit 0840b41

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

Lib/pydoc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2431,8 +2431,8 @@ def log_message(self, *args):
24312431
class DocServer(http.server.HTTPServer):
24322432

24332433
def __init__(self, port, callback):
2434-
self.host = (sys.platform == 'mac') and '127.0.0.1' or 'localhost'
2435-
self.address = ('', port)
2434+
self.host = 'localhost'
2435+
self.address = (self.host, port)
24362436
self.callback = callback
24372437
self.base.__init__(self, self.address, self.handler)
24382438
self.quit = False

Lib/test/test_pydoc.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,8 @@ def my_url_handler(url, content_type):
510510
return text
511511

512512
serverthread = pydoc._start_server(my_url_handler, port=0)
513+
self.assertIn('localhost', serverthread.docserver.address)
514+
513515
starttime = time.time()
514516
timeout = 1 #seconds
515517

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ What's New in Python 3.2.6?
1010
Library
1111
-------
1212

13+
- Issue #22421: Fix a regression that caused the pydoc server to be bound to
14+
all interfaces instead of only localhost.
15+
1316
- Issue #22419: Limit the length of incoming HTTP request in wsgiref server to
1417
65536 bytes and send a 414 error code for higher lengths. Patch contributed
1518
by Devin Cook.

0 commit comments

Comments
 (0)
0