Skip to content

Commit 5f1e535

Browse files
rounak610claude
andcommitted
Add comment explaining each guard in validateSourceUrl
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent c1bb0f7 commit 5f1e535

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/main/java/com/browserstack/local/LocalBinary.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ class LocalBinary {
4545
System.getProperty("java.io.tmpdir")
4646
};
4747

48+
// Each guard below covers a case the final host-equals check does not:
49+
// - null/empty URL: new URL(null) throws NPE before the catch can run.
50+
// - MalformedURLException: convert raw JVM exception to LocalException for the public contract.
51+
// - HTTPS check: allowlist matches host only; without this, http://browserstack.com would pass.
52+
// - null/empty host: getHost() returns null for URLs like https:///foo, which NPEs on toLowerCase().
4853
private static String validateSourceUrl(String url) throws LocalException {
4954
if (url == null || url.isEmpty()) {
5055
throw new LocalException("Refusing binary download: empty source URL");

0 commit comments

Comments
 (0)