Skip to content

Commit 50598ad

Browse files
joke1196sonartech
authored andcommitted
SONARPY-3887 Fix QG (#946)
GitOrigin-RevId: 77b6559037e7b34eaadbfa82a7b6192ff2bf3dd2
1 parent daefc87 commit 50598ad

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

python-checks/src/main/java/org/sonar/python/checks/hotspots/HardCodedCredentialsCheck.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
package org.sonar.python.checks.hotspots;
1818

1919
import java.net.MalformedURLException;
20+
import java.net.URI;
21+
import java.net.URISyntaxException;
2022
import java.net.URL;
2123
import java.util.Collection;
2224
import java.util.Collections;
@@ -270,12 +272,12 @@ private static boolean isURLWithCredentials(StringLiteral stringLiteral) {
270272
return false;
271273
}
272274
try {
273-
URL url = new URL(stringLiteral.trimmedQuotesValue());
275+
URL url = new URI(stringLiteral.trimmedQuotesValue()).toURL();
274276
String userInfo = url.getUserInfo();
275277
if (userInfo != null && userInfo.matches("\\S+:\\S+")) {
276278
return true;
277279
}
278-
} catch (MalformedURLException e) {
280+
} catch (URISyntaxException | MalformedURLException | IllegalArgumentException e) {
279281
return false;
280282
}
281283
return false;

0 commit comments

Comments
 (0)