Skip to content

Missing Parameters Without Values in IOwinRequest.Query Dictionary #540

Open
@chupAkabRRa

Description

@chupAkabRRa

Description

While creating a custom LoggingMiddleware, we encountered an issue where parameters without a value are not included in the IOwinRequest.Query dictionary. Our use case requires logging all parameters passed to our service, but parameters with no associated value and no "=" sign (e.g., ?param) are omitted from the query dictionary.

To resolve this, we had to manually parse the QueryString. This behavior is not explicitly documented, and it was unexpected.

Proposed Fix

I believe the issue lies in the ParseDelimited() method in src/Microsoft.Owin/Infrastructure/OwinHelpers.cs. The following check:

if (equalIndex < delimiterIndex)

ignores the possibility of parsing parameters without a corresponding value.

Steps to Reproduce

  1. Create a middleware that inspects the IOwinRequest.Query dictionary.
  2. Send a request with a query string containing parameters without values and without "=" sign (e.g., ?param1=1&param2).
  3. Notice that param2 is missing from the Query dictionary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions