BaseHTTPRequestHandler.parse_request() loses client-provided information
オープン
まだ誰も着手していません。
stdlib
type-bug
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 36k
- PR マージ指標
- PR 指標を取得中
説明
Bug report
The fix for https://github.com/python/cpython/issues/87389 prevents servers from handling request paths with multiple leading slashes.
For example, one might have a simple server that just reflects the request path:
from http.server import *
class MyHTTPRequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.end_headers()
self.wfile.write(self.path.encode('latin1'))
with ThreadingHTTPServer(('127.0.0.1', 8000), MyHTTPRequestHandler) as server:
server.serve_forever()
Previously, this would faithfully mirror the request path from the client:
$ curl -v http://localhost:8000//test
* Trying 127.0.0.1:8000...
* Connected to localhost (127.0.0.1) port 8000 (#0)
> GET //test HTTP/1.1
> Host: localhost:8000
> User-Agent: curl/7.82.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
< Server: BaseHTTP/0.6 Python/3.8.13
< Date: Mon, 07 Nov 2022 21:51:19 GMT
<
* Closing connection 0
//test
But now it mangles it:
$ curl -v http://localhost:8000//test
* Trying 127.0.0.1:8000...
* Connected to localhost (127.0.0.1) port 8000 (#0)
> GET //test HTTP/1.1
> Host: localhost:8000
> User-Agent: curl/7.82.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
< Server: BaseHTTP/0.6 Python/3.11.0
< Date: Mon, 07 Nov 2022 21:51:30 GMT
<
* Closing connection 0
/test
This impacts any servers that subclass BaseHTTPRequestHandler, such as eventlet's WSGI server.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
BaseHTTPRequestHandler.parse_request() から始め、//test リクエストの現在の処理を、報告に示されている動作と比較します。issue 87389 に関連する変更を追跡し、クライアントが提供したパスがどこで変更されるのかを特定します。サンプルサーバーのようなサブクラスが、リクエスト検証を後退させることなく、元の先頭スラッシュを受け取れるようになれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- backend-api-design, networking
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100