Repository navigation
Treat *.example.com in NO_PROXY like .example.com - #1277
RaphaelFakhri wants to merge 1 commit into
Conversation
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
1 issue found across 3 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/httpx2/httpx2/_utils.py">
<violation number="1" location="src/httpx2/httpx2/_utils.py:78">
P2: This branch accepts slash-bearing wildcard entries such as `NO_PROXY=*.example.com/path`, then `URLPattern` ignores the path and bypasses the proxy for the entire wildcard domain. Keep the existing slash guard on this branch so malformed non-CIDR entries are ignored while wildcard ports remain supported.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
| mounts[f"all://{hostname}"] = None | ||
| elif hostname.startswith("["): | ||
| mounts[f"all://{hostname}"] = None | ||
| elif hostname.startswith("*."): |
There was a problem hiding this comment.
P2: This branch accepts slash-bearing wildcard entries such as NO_PROXY=*.example.com/path, then URLPattern ignores the path and bypasses the proxy for the entire wildcard domain. Keep the existing slash guard on this branch so malformed non-CIDR entries are ignored while wildcard ports remain supported.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At src/httpx2/httpx2/_utils.py, line 78:
<comment>This branch accepts slash-bearing wildcard entries such as `NO_PROXY=*.example.com/path`, then `URLPattern` ignores the path and bypasses the proxy for the entire wildcard domain. Keep the existing slash guard on this branch so malformed non-CIDR entries are ignored while wildcard ports remain supported.</comment>
<file context>
@@ -75,6 +75,9 @@ def get_environment_proxies() -> dict[str, str | None]:
mounts[f"all://{hostname}"] = None
elif hostname.startswith("["):
mounts[f"all://{hostname}"] = None
+ elif hostname.startswith("*."):
+ # NO_PROXY=*.google.com is treated like .google.com
+ mounts[f"all://{hostname}"] = None
</file context>
| elif hostname.startswith("*."): | |
| elif hostname.startswith("*.") and "/" not in hostname: |
Summary
A
NO_PROXYentry such as*.example.comnever matches.get_environment_proxies()prepends*to plain hostnames, which turns the entry intoall://**.example.com, andURLPatterncompiles that to^(.+\.)?\*\.example\.com$. Requests towww.example.comstill go through the proxy.This change maps a leading
*.to the same mount key as a leading.(all://*.example.com), so the entry matches subdomains ofexample.com. Go'snet/httphandles*.the same way.Checklist
Fixes #1276