Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-73561: Omit interface scope from IPv6 when used as Host header#93324

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

@mib1185
Copy link
Contributor

@mib1185mib1185 commentedMay 28, 2022
edited by bedevere-bot
Loading

This will omit the interface scope from IPv6 when used as Host header.
This should also be back ported to all maintenance releases.

@ghost
Copy link

ghost commentedMay 28, 2022
edited by ghost
Loading

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-bot
Copy link

Most changes to Pythonrequire a NEWS entry.

Please add it using theblurb_it web app or theblurb command-line tool.

@bedevere-bot
Copy link

Most changes to Pythonrequire a NEWS entry.

Please add it using theblurb_it web app or theblurb command-line tool.

@mib1185mib1185force-pushed thelib/http/omit-scope-from-IPv6-when-used-as-Host-header branch 2 times, most recently froma10bb09 to9290a01CompareMay 28, 2022 20:44
@mib1185mib1185force-pushed thelib/http/omit-scope-from-IPv6-when-used-as-Host-header branch from9290a01 to937cb17CompareSeptember 18, 2022 22:15
@mib1185
Copy link
ContributorAuthor

mib1185 commentedSep 18, 2022
edited
Loading

@gpshead,@vadmium sorry to bother you directly ... you may not remember this topic, because it is 5 years ago 🙈 but i hope you are still interested in this and may have a look into this PR? 🙂

@mib1185
Copy link
ContributorAuthor

@vstinner do you mind to have a look into the last changes?

@mib1185
Copy link
ContributorAuthor

hi, is there any possibility, to get this small PR reviewed? I don't want to blame anybody direct, therefore i already followed the suggested way with "pinging" the connected issue and writing to the forum, but without success 🙁

@gpsheadgpshead self-assigned thisNov 19, 2023
@gpsheadgpshead added needs backport to 3.11only security fixes needs backport to 3.12only security fixes labelsNov 19, 2023

# remove interface scope from IPv6 address
# when used as Host header
if"%"innetloc:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

rather than checking netloc and modifying netloc_enc (which makes assumptions about the encoding - granted they're accurate so the logic works), how about doing this using the partition method for a single scan / split operation?

netloc_enc,percent,unused_iface=netloc_enc.partition(b"%")ifpercent:netloc_enc+=b"]"

do similar with host_enc below.

There is technically a logic flaw in the current code, it's using netloc.find as an index into the encoded netloc_enc value. (same with host vs host_enc). the stripping should be done more directly from the same thing used for find. partition will do that.

As this is done in two places, it'd be nice to turn it into a private helper function, put that logic in a top leveldef _strip_ipv6_iface(enc_name: bytes) -> bytes: function perhaps?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

hi@gpshead
thank you for your review and your suggestion, which sounds very reasonable ... i've applied it now

@mib1185mib1185force-pushed thelib/http/omit-scope-from-IPv6-when-used-as-Host-header branch from1283ff9 to43fc859CompareNovember 19, 2023 20:19
@mib1185
Copy link
ContributorAuthor

rebased to currentmain tohopefully fix the docs related tests

@gpsheadgpshead added the type-bugAn unexpected behavior, bug, or error labelNov 19, 2023
@gpsheadgpsheadenabled auto-merge (squash)November 19, 2023 22:29
@gpsheadgpshead merged commitce1096f intopython:mainNov 19, 2023
@miss-islington-app
Copy link

Thanks@mib1185 for the PR, and@gpshead for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestNov 19, 2023
…er (pythonGH-93324)Omit the `@interface_scope` from an IPv6 address when used as Host header by `http.client`.---------(cherry picked from commitce1096f)Co-authored-by: Michael <35783820+mib1185@users.noreply.github.com>Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google LLC]
miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestNov 19, 2023
…er (pythonGH-93324)Omit the `@interface_scope` from an IPv6 address when used as Host header by `http.client`.---------(cherry picked from commitce1096f)Co-authored-by: Michael <35783820+mib1185@users.noreply.github.com>Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google LLC]
@bedevere-app
Copy link

GH-112272 is a backport of this pull request to the3.12 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.12only security fixes labelNov 19, 2023
@bedevere-app
Copy link

GH-112273 is a backport of this pull request to the3.11 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.11only security fixes labelNov 19, 2023
@mib1185mib1185 deleted the lib/http/omit-scope-from-IPv6-when-used-as-Host-header branchNovember 19, 2023 22:39
@mib1185
Copy link
ContributorAuthor

Many thanks@gpshead for your support to get this ready and merged 🤝

gpshead reacted with thumbs up emoji

@gpshead
Copy link
Member

thanks for the fix!

gpshead pushed a commit that referenced this pull requestNov 19, 2023
…der (GH-93324) (#112272)gh-73561: Omit interface scope from IPv6 when used as Host header (GH-93324)Omit the `@interface_scope` from an IPv6 address when used as Host header by `http.client`.---------(cherry picked from commitce1096f) [Google LLC]Co-authored-by: Michael <35783820+mib1185@users.noreply.github.com>
gpshead pushed a commit that referenced this pull requestNov 19, 2023
…der (GH-93324) (#112273)gh-73561: Omit interface scope from IPv6 when used as Host header (GH-93324)Omit the `@interface_scope` from an IPv6 address when used as Host header by `http.client`.---------(cherry picked from commitce1096f) [Google LLC]Co-authored-by: Michael <35783820+mib1185@users.noreply.github.com>
aisk pushed a commit to aisk/cpython that referenced this pull requestFeb 11, 2024
…er (python#93324)Omit the `@interface_scope` from an IPv6 address when used as Host header by `http.client`.---------Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google LLC]
Glyphack pushed a commit to Glyphack/cpython that referenced this pull requestSep 2, 2024
…er (python#93324)Omit the `@interface_scope` from an IPv6 address when used as Host header by `http.client`.---------Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google LLC]
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@vstinnervstinnerAwaiting requested review from vstinner

@gpsheadgpsheadAwaiting requested review from gpshead

Assignees

@gpsheadgpshead

Labels

type-bugAn unexpected behavior, bug, or error

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

httplib: wrong Host header when connecting to IPv6 link-local address

4 participants

@mib1185@bedevere-bot@gpshead@vstinner

[8]ページ先頭

©2009-2025 Movatter.jp