Skip to content

support headers with multiple colons in value (e.g. CSP)#217

Merged
umputun merged 2 commits intomasterfrom
fix-header-parsing
Feb 20, 2025
Merged

support headers with multiple colons in value (e.g. CSP)#217
umputun merged 2 commits intomasterfrom
fix-header-parsing

Conversation

@umputun
Copy link
Owner

@umputun umputun commented Feb 20, 2025

The current header parsing logic splits headers on all colons, which breaks headers containing colons in their values, such as Content-Security-Policy with URLs (https://example.com:443) or other complex directives.

This PR changes the header parsing to only split on the first colon, preserving any subsequent colons in the header value. This allows proper handling of:

  • Content-Security-Policy with URLs and complex directives

  • Custom headers with colons in values

  • Other standard headers that may contain colons

  • Before the fix:

HEADER=Content-Security-Policy:default-src 'self'; style-src 'self' https://example.com:443

Would incorrectly split into multiple parts at each colon.

  • After the fix:

The header value is properly preserved with all its colons intact.

Added tests to verify proper handling of complex header values.

@umputun umputun merged commit 3a204ef into master Feb 20, 2025
2 checks passed
@umputun umputun deleted the fix-header-parsing branch February 20, 2025 18:06
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.

1 participant