Skip to content

HTTP client non proxy host matching is not aligned with documentation #6419

@maff

Description

@maff

Describe the Bug

The current implementation if the non-proxy-host matching in the HTTP client support currently treats the whole host as regex pattern, leading to . matching any character instead of only a dot. According to our docs, only * are allowed as wildcards at the beginning and the end of a host (host patterns delimited by |:

Specify as a list of patterns, separated by |.
Patterns can start or end with a * for wildcards.

Steps to Reproduce

Background to find this was this Copilot comment:

toRegex currently only replaces * with .* and leaves other regex metacharacters (notably .) unescaped. This means patterns like example.de will match unintended hosts (e.g. exampleXde) because . is treated as “any char”, which differs from the documented http.nonProxyHosts semantics where . is literal. Consider escaping regex metacharacters (e.g., via Pattern.quote per token) while still supporting * wildcards and | separators, and extend the tests to cover these edge cases.

Expected Behavior

Regex patterns within a host pattern are treated as normal chars as documented. example.de does not match exampleXde.

Environment

  • Library version: 8.9.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions