Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
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
gh-73561: Omit interface scope from IPv6 when used as Host header#93324
Uh oh!
There was an error while loading.Please reload this page.
Conversation
ghost commentedMay 28, 2022 • edited by ghost
Loading Uh oh!
There was an error while loading.Please reload this page.
edited by ghost
Uh oh!
There was an error while loading.Please reload this page.
bedevere-bot commentedMay 28, 2022
Most changes to Pythonrequire a NEWS entry. Please add it using theblurb_it web app or theblurb command-line tool. |
bedevere-bot commentedMay 28, 2022
Most changes to Pythonrequire a NEWS entry. Please add it using theblurb_it web app or theblurb command-line tool. |
a10bb09 to9290a01Compare9290a01 to937cb17Comparemib1185 commentedSep 18, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
mib1185 commentedSep 10, 2023
@vstinner do you mind to have a look into the last changes? |
mib1185 commentedNov 19, 2023
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 🙁 |
Lib/http/client.py Outdated
| # remove interface scope from IPv6 address | ||
| # when used as Host header | ||
| if"%"innetloc: |
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.
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?
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.
hi@gpshead
thank you for your review and your suggestion, which sounds very reasonable ... i've applied it now
1283ff9 to43fc859Comparemib1185 commentedNov 19, 2023
rebased to current |
…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]
…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]
GH-112272 is a backport of this pull request to the3.12 branch. |
GH-112273 is a backport of this pull request to the3.11 branch. |
mib1185 commentedNov 19, 2023
Many thanks@gpshead for your support to get this ready and merged 🤝 |
gpshead commentedNov 19, 2023
thanks for the fix! |
…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>
…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>
…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]
…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]
Uh oh!
There was an error while loading.Please reload this page.
This will omit the interface scope from IPv6 when used as Host header.
This should also be back ported to all maintenance releases.