Repository navigation
Fix HTTP request authority port parsing - #16551
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 3.3 #16551 +/- ##
============================================
+ Coverage 60.90% 60.93% +0.02%
- Complexity 15 11765 +11750
============================================
Files 1953 1953
Lines 89280 89282 +2
Branches 13476 13477 +1
============================================
+ Hits 54376 54404 +28
+ Misses 29323 29290 -33
- Partials 5581 5588 +7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
EarthChen
left a comment
There was a problem hiding this comment.
LGTM. Confirmed the bug: the old serverPort() parsed the part before the colon, so Host: localhost:8013 threw NumberFormatException (reachable via CorsHeaderFilter when an Origin header is present). serverName() also truncated IPv6 hosts such as [2001:db8::1]. getHostPortSeparator handles host, host:port, [v6] and [v6]:port correctly, and the new tests cover these cases.
Non-blocking: Host: host: or a non-numeric port still throws NumberFormatException (existing behavior).
What is the purpose of the change?
Fixes #16547.
DefaultHttpRequest.serverPort() attempted to parse the host portion of an authority as an integer. This change parses the port suffix and avoids treating colons inside bracketed IPv6 addresses as port separators in serverName() and serverPort().
Verification
Checklist