Commit a9bd0c5
committed
Fix IPv6 Zone ID decoding to correctly handle RFC 6874 %25 separator
Per RFC 6874, an IPv6 Zone ID in a URI is encoded as:
IPv6addrz = IPv6address "%25" ZoneID
So in 'http://[fe80::1%251]/', the zone ID is '1', not '251'.
Previously, _encode_host() split the host on bare '%', treating '251'
as the zone ID. The host property also returned the raw (encoded)
value unchanged for IP addresses, so %25 was never decoded.
Fix _encode_host() to partition on '%25' (RFC 6874 separator) when
present, preserving it verbatim in raw_host / str(url), and update
the host property to decode '%25' -> '%' so callers receive the
human-readable zone identifier (e.g. 'fe80::1%1' / 'fe80::1%eth0').
Tests added for:
- Numeric zone ID: http://[fe80::1%251]/ -> host='fe80::1%1'
- String zone ID: http://[fe80::1%25eth0]/ -> host='fe80::1%eth0'1 parent 2f180d1 commit a9bd0c5
2 files changed
Lines changed: 17 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
373 | 373 | | |
374 | 374 | | |
375 | 375 | | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
376 | 384 | | |
377 | 385 | | |
378 | 386 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
764 | 764 | | |
765 | 765 | | |
766 | 766 | | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
767 | 770 | | |
768 | 771 | | |
769 | 772 | | |
| |||
1550 | 1553 | | |
1551 | 1554 | | |
1552 | 1555 | | |
1553 | | - | |
| 1556 | + | |
| 1557 | + | |
| 1558 | + | |
| 1559 | + | |
1554 | 1560 | | |
1555 | 1561 | | |
1556 | 1562 | | |
| |||
1578 | 1584 | | |
1579 | 1585 | | |
1580 | 1586 | | |
1581 | | - | |
1582 | | - | |
| 1587 | + | |
| 1588 | + | |
1583 | 1589 | | |
1584 | 1590 | | |
1585 | 1591 | | |
| |||
0 commit comments