Skip to content

Improve HTTP header parsing to handle quoted strings with delimiters #102

Open

Description

@coderabbitai

Problem

The current HTTP header parsing implementation in the codebase uses naive string splitting methods that fail when quoted values contain delimiter characters. This affects the ForwardedHeader implementation and potentially other header parsers.

Example Issue

A header value like:

for="[2001:db8:cafe::17]:4711";desc="semi;colon"

Will be incorrectly parsed because the simple split(';') and split('=') methods don't respect quoted strings and escapes.

Current Implementation

The parsing uses:

final pairStrings = elementStr.split(';');
final parts = pairStr.split('=');

Suggested Solutions

  1. Reuse HeaderValue.parse from package:http_parser <-- no such thing
  2. Implement a custom state machine that properly handles quoted strings and escapes
  3. Use a proper HTTP header parser that respects RFC standards

Impact

This is a broader architectural issue that could affect multiple header types beyond just the Forwarded header.

References

Activity

  1. nielsenko commented on Jun 17, 2025

    @nielsenko
    Collaborator

    There is no such thing as HeaderValue.parse exported from the http_parser (@coderabbitai is hallucinating), but we may steal the private scan.dart file and build on that.

  2. deleted a comment from coderabbitai on Aug 5, 2025
  3. deleted a comment from coderabbitai on Aug 5, 2025
  4. moved this from Inbox 📫 to Backlog 🗂️ in Serverpod Frameworkson Aug 14, 2025
  5. SandPod commented on Aug 14, 2025

    @SandPod
    Contributor

    Relates to #113

  6. added
    bug
    area: headers
    on Oct 23, 2025
  7. moved this from Backlog 🗂️ to Planned 🔭 in Serverpod Frameworkson Oct 23, 2025
  8. moved this from Planned 🔭 to Backlog 🗂️ in Serverpod Frameworkson Oct 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: headersbug

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions