Skip to content

Commit 70ba555

Browse files
Check if the url really starts with "https" or "http"
1 parent 6c8440a commit 70ba555

File tree

1 file changed

+8
-6
lines changed
  • src/main/java/net/javadiscord/javabot/systems/moderation

1 file changed

+8
-6
lines changed

src/main/java/net/javadiscord/javabot/systems/moderation/AutoMod.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,13 +203,15 @@ public boolean hasSuspiciousLink(@NotNull Message message) {
203203
// only do it for a links, so it won't iterate for each message
204204
while (urlMatcher.find()) {
205205
String url = urlMatcher.group(0).trim();
206-
try {
207-
URI uri = new URI(url);
208-
if (uri.getHost() != null && spamUrls.contains(uri.getHost())) {
209-
return true;
206+
if (url.startsWith("http://") || url.startsWith("https://")) {
207+
try {
208+
URI uri = new URI(url);
209+
if (uri.getHost() != null && spamUrls.contains(uri.getHost())) {
210+
return true;
211+
}
212+
} catch (URISyntaxException e) {
213+
ExceptionLogger.capture(e, getClass().getSimpleName());
210214
}
211-
} catch (URISyntaxException e) {
212-
ExceptionLogger.capture(e, getClass().getSimpleName());
213215
}
214216
}
215217
}

0 commit comments

Comments
 (0)