Repository navigation
fix: decoded host size for IPv6 zone IDs - #1005
Conversation
|
An automated preview of the documentation is available at https://1005.url.prtest2.cppalliance.org/index.html If more commits are pushed to the pull request, the docs will rebuild at the same URL. 2026-10-13 02:35:11 UTC |
|
GCOVR code coverage report https://1005.url.prtest2.cppalliance.org/gcovr/index.html Build time: 2026-10-13 02:48:04 UTC |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1005 +/- ##
========================================
Coverage 99.12% 99.12%
========================================
Files 154 154
Lines 10093 10103 +10
========================================
+ Hits 10005 10015 +10
Misses 88 88
... and 1 file with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
The host rule stored the encoded size of an IPv6 literal as its
decoded size. A zone ID shrinks when decoded ("%25" becomes "%",
and the zone ID itself may contain pct-encoded octets), so the
stored size overshot and every accessor that decodes the host
produced a string with trailing garbage:
url_view u("http://[fe80::1%25eth0]/");
u.host_address(); // "fe80::1%eth0\0\0", size 14 instead of 12
The ip_literal_rule now forwards the zone ID parsed by
ipv6_addrz_rule, and the host rule derives the decoded size from it.
The assertion in encoded_host_address() compared the decoded size
with the encoded size, which only holds without a zone ID, and had
been relaxed in url_view_base to tolerate the wrong value. It is
removed from both url_view_base and authority_view: the invariant
is covered by tests, like every other encoded_* accessor. Checking
it exposed three more bookkeeping bugs in the same family, fixed
here as well:
- remove_authority() left the decoded sizes of the removed user,
password and host behind, so encoded_authority().decoded_size()
was non-zero on a URL without an authority.
- encoded_authority() never counted the "@" separator nor the port,
so url_view("http://host:8080/").encoded_authority().decode()
returned "host".
- format() stored the bracketed host size without the closing "]",
and counted the ":" delimiter in the password and port sizes, so
format("http://[fe80::1]/").host() returned "[fe80::1".
The existing issue boostorg#919 regression test is kept as is. New tests
cover the parser, authority_view, the url setters, remove_authority
and format with zone IDs, pct-encoded zone IDs, userinfo and ports.
Thanks to Sergei Zimmerman for identifying the issue in boostorg#1004.
Closes boostorg#1004
dbac83d to
841f0a5
Compare
The host rule stored the encoded size of an IPv6 literal as its decoded size. A zone ID shrinks when decoded ("%25" becomes "%", and the zone ID itself may contain pct-encoded octets), so the stored size overshot and every accessor that decodes the host produced a string with trailing garbage:
The ip_literal_rule now forwards the zone ID parsed by ipv6_addrz_rule, and the host rule derives the decoded size from it.
The assertion in encoded_host_address() compared the decoded size with the encoded size, which only holds without a zone ID, and had been relaxed in url_view_base to tolerate the wrong value. It is removed from both url_view_base and authority_view: the invariant is covered by tests, like every other encoded_* accessor. Checking it exposed three more bookkeeping bugs in the same family, fixed here as well:
The existing issue #919 regression test is kept as is. New tests cover the parser, authority_view, the url setters, remove_authority and format with zone IDs, pct-encoded zone IDs, userinfo and ports.
Thanks to Sergei Zimmerman for identifying the issue in #1004.
Closes #1004