From 6c375f0cb5aac2644abbfbe36f2b1b9c32d5b47f Mon Sep 17 00:00:00 2001 From: Allink Date: Sat, 8 Apr 2023 16:49:46 +0100 Subject: [PATCH] Make URL regex stricter --- .../java/pw/kaboom/extras/modules/player/PlayerChat.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/pw/kaboom/extras/modules/player/PlayerChat.java b/src/main/java/pw/kaboom/extras/modules/player/PlayerChat.java index a282f28..89052d3 100644 --- a/src/main/java/pw/kaboom/extras/modules/player/PlayerChat.java +++ b/src/main/java/pw/kaboom/extras/modules/player/PlayerChat.java @@ -49,8 +49,8 @@ public final class PlayerChat implements Listener { TextReplacementConfig .builder() .match(Pattern - .compile("((https?://(www\\.)?)?[-a-zA-Z0-9@:%._+~#=]" + - "{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_+.~#?&/=]*))")) + .compile("((https?://(ww(w|\\d)\\.)?|ww(w|\\d))[-a-zA-Z0-9@:%._+~#=]{1,256}" + + "\\.[a-zA-Z0-9]{2,6}\\b([-a-zA-Z0-9@:%_+.~#?&/=]*))")) .replacement((b, c) -> { if (c == null) { return null; @@ -64,7 +64,7 @@ public final class PlayerChat implements Listener { final String url; /* - Minecraft doesn't accept "www.google.com" or "google.com" as URLs + Minecraft doesn't accept "www.google.com" as a URL in click events */ if (content.contains("://")) {