[rh:urllib] Fix relative redirects with dot segments (#17712)

Authored by: doe1080
This commit is contained in:
doe1080
2026-09-27 19:55:49 +02:00
committed by GitHub
parent f9eee6ba62
commit c2901ed367
2 changed files with 7 additions and 11 deletions
+6
View File
@@ -180,6 +180,11 @@ class HTTPTestRequestHandler(http.server.BaseHTTPRequestHandler):
self.send_header('Location', '/a/b/./../../headers')
self.send_header('Content-Length', '0')
self.end_headers()
elif self.path == '/a/b/redirect_relative_dotsegments':
self.send_response(301)
self.send_header('Location', '../../headers')
self.send_header('Content-Length', '0')
self.end_headers()
elif self.path == '/redirect_dotsegments_absolute':
self.send_response(301)
# redirect to /headers but with dot segments before - absolute url
@@ -412,6 +417,7 @@ class TestHTTPRequestHandler(TestRequestHandlerBase):
@pytest.mark.parametrize('path', [
'/a/b/./../../headers',
'/redirect_dotsegments',
'/a/b/redirect_relative_dotsegments',
# https://github.com/yt-dlp/yt-dlp/issues/9020
'/redirect_dotsegments_absolute',
])