Skip to content

Fix #59: Parse comma-separated IP chains in non-RFC forwarded headers - #60

Merged
samdark merged 1 commit into
masterfrom
fix/x-forwarded-for-comma-separated
Aug 31, 2026
Merged

Fix #59: Parse comma-separated IP chains in non-RFC forwarded headers#60
samdark merged 1 commit into
masterfrom
fix/x-forwarded-for-comma-separated

Conversation

@samdark

@samdark samdark commented Aug 31, 2026

Copy link
Copy Markdown
Member
  • parse comma-separated IP chains from non-RFC forwarded headers
  • preserve PSR-7 header value order and trim optional whitespace
  • reject malformed empty chain entries through existing IP validation
  • document the behavior and add regression coverage for X-Forwarded-For and custom headers

Fixes #59

Copilot AI lite review requested due to automatic review settings August 31, 2026 07:55
@codecov

codecov Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.67%. Comparing base (e6f3d84) to head (224ec97).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-For and 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.

@samdark samdark changed the title Fix parsing comma-separated forwarded IPs Fix #59: Parse comma-separated IP chains in non-RFC forwarded headers Aug 31, 2026
@samdark
samdark merged commit cb7d46b into master Aug 31, 2026
29 checks passed
@samdark
samdark deleted the fix/x-forwarded-for-comma-separated branch August 31, 2026 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TrustedHostsNetworkResolver does not split comma-separated X-Forwarded-For

2 participants