Fix #59: Parse comma-separated IP chains in non-RFC forwarded headers - #60
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #60 +/- ##
=========================================
Coverage 98.67% 98.67%
+ Complexity 142 141 -1
=========================================
Files 3 3
Lines 376 378 +2
=========================================
+ Hits 371 373 +2
Misses 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR fixes issue #59 by teaching TrustedHostsNetworkResolver to correctly parse common proxy behavior where X-Forwarded-For (and similar non-RFC “separate header group” IP headers) arrive as a single comma-separated header line in PSR-7 requests, splitting and trimming the IP chain before validation/chain resolution.
Changes:
- Update non-RFC forwarded header parsing to split comma-separated IP chains (using PSR-7
getHeaderLine()), trimming optional whitespace and letting existing IP validation reject empty segments. - Add/adjust PHPUnit coverage for comma-separated
X-Forwarded-Forand custom header groups, including multiple header values. - Document the new behavior in README and note the fix in the changelog.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/TrustedHostsNetworkResolver.php |
Parse non-RFC forwarded IP header lines as comma-separated lists (trimmed) before building the connection chain. |
tests/TrustedHostsNetworkResolver/ProcessTest.php |
Add regression tests for comma-separated IP chains in X-Forwarded-For and custom headers (including multiple header values). |
tests/TrustedHostsNetworkResolver/RuntimeExceptionTest.php |
Add coverage ensuring empty comma-separated segments are rejected via existing IP validation. |
README.md |
Document comma-separated parsing behavior and combination of multiple header values in original order. |
CHANGELOG.md |
Record the bugfix for #59 under the next development version. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Fixes #59