fix(fetch): fix SOCKS5 proxy URL validation logic#31604
fix(fetch): fix SOCKS5 proxy URL validation logic#31604bartlomieju merged 1 commit intodenoland:mainfrom
Conversation
WalkthroughThe pull request relaxes Socks5 proxy URL validation in the HTTP client: the check now throws only if the proxy URL does not start with Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used📓 Path-based instructions (1)**/*.{ts,tsx,js}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
🧬 Code graph analysis (1)ext/fetch/22_http_client.js (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
🔇 Additional comments (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The condition for validating SOCKS5 proxy URLs was using `||` (OR) instead of `&&` (AND), which caused valid socks5:// and socks5h:// URLs to always throw a TypeError. The correct logic should only throw when the URL does NOT start with "socks5:" AND does NOT start with "socks5h:". Closes denoland#31356
0efde7f to
e7f1ed9
Compare
bartlomieju
left a comment
There was a problem hiding this comment.
I verified that this fails on main. Thanks!
|
Happy to help. |
Summary
This PR fixes a logical error in the SOCKS5 proxy URL validation in
Deno.createHttpClient().The bug: The condition for validating SOCKS5 proxy URLs was using
||(OR) instead of&&(AND):This meant that a valid
socks5://URL would still throw because it doesn't start withsocks5h:, and vice versa. The condition would almost always be true, making SOCKS5 proxies unusable.The fix:
Now the error is only thrown when the URL starts with NEITHER
socks5:norsocks5h:.Changes
||to&&socks5://andsocks5h://URLsTest plan
createHttpClientSocks5ProxyAcceptsSocks5Url- verifies socks5 transport accepts socks5:// URLscreateHttpClientSocks5ProxyAcceptsSocks5hUrl- verifies socks5 transport accepts socks5h:// URLsCloses #31356