-
-
Notifications
You must be signed in to change notification settings - Fork 16.9k
Fix `.partition(":") usage on potential IPv6 addresses #6096
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: stable
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ | |
| from itertools import chain | ||
| from types import TracebackType | ||
| from urllib.parse import quote as _url_quote | ||
| from urllib.parse import urlsplit | ||
|
|
||
| import click | ||
| from werkzeug.datastructures import Headers | ||
|
|
@@ -635,7 +636,9 @@ def run( | |
| sn_host = sn_port = None | ||
|
|
||
| if server_name: | ||
| sn_host, _, sn_port = server_name.partition(":") | ||
| server_url = urlsplit(f"//{server_name}") | ||
| sn_host = server_url.hostname | ||
| sn_port = server_url.port | ||
|
|
||
| if not host: | ||
| if sn_host: | ||
|
|
@@ -645,8 +648,8 @@ def run( | |
|
|
||
| if port or port == 0: | ||
| port = int(port) | ||
| elif sn_port: | ||
| port = int(sn_port) | ||
| elif sn_port is not None: | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| port = sn_port | ||
| else: | ||
| port = 5000 | ||
|
|
||
|
|
@@ -659,7 +662,7 @@ def run( | |
| from werkzeug.serving import run_simple | ||
|
|
||
| try: | ||
| run_simple(t.cast(str, host), port, self, **options) | ||
| run_simple(host, port, self, **options) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mypy: Redundant cast to "str" |
||
| finally: | ||
| # reset the first request information if the development server | ||
| # reset normally. This makes it possible to restart the server | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -177,7 +177,7 @@ def session_transaction( | |
| app.session_interface.save_session(app, sess, resp) | ||
|
|
||
| self._update_cookies_from_response( | ||
| ctx.request.host.partition(":")[0], | ||
| urlsplit(ctx.request.host_url).hostname or "localhost", | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's the part I was unsure about.
|
||
| ctx.request.path, | ||
| resp.headers.getlist("Set-Cookie"), | ||
| ) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added "//" to make urlsplit work in this instance. I assume that this won't break anything, but you definitely know more about that.