Skip to content

AI junk - #6131

Closed
ameerhmz wants to merge 1 commit into
pallets:mainfrom
ameerhmz:fix/parse-ipv6-server-name-and-host
Closed

AI junk#6131
ameerhmz wants to merge 1 commit into
pallets:mainfrom
ameerhmz:fix/parse-ipv6-server-name-and-host

Conversation

@ameerhmz

Copy link
Copy Markdown

What does this PR do?

Fixes #6093 where IPv6 addresses (e.g. [::1]:8080 or http://[::1]:8000/) were parsed incorrectly using .partition(":"), causing string splits on colons inside IPv6 host brackets.

Root Cause

  1. In src/flask/app.py: server_name.partition(":") split "[::1]:8080" into sn_host = "[", sn_port = ":1]:8080".
  2. In src/flask/testing.py: ctx.request.host.partition(":")[0] returned "[" instead of normalized IPv6 host "::1".

Solution

  1. Updated src/flask/app.py SERVER_NAME parsing to check for "]:" or rpartition(":") to extract IPv6 host and port correctly.
  2. Updated src/flask/testing.py session_transaction cookie host parsing to handle IPv6 bracketed hosts.
  3. Added test case in tests/test_basic.py test_run_from_config for [::1]:8080.
  4. Added test_session_transaction_ipv6 in tests/test_testing.py.

@davidism

Copy link
Copy Markdown
Member

@davidism davidism closed this Aug 10, 2026
@davidism davidism changed the title fix: safely parse IPv6 server name and test host (Fixes #6093) AI junk Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IPv6 addresses parsed incorrectly because of .partition(":")?

2 participants