Make URL regex stricter

This commit is contained in:
Allink 2023-04-08 16:49:46 +01:00
parent 4d2455d45b
commit 6c375f0cb5
No known key found for this signature in database

View file

@ -49,8 +49,8 @@ public final class PlayerChat implements Listener {
TextReplacementConfig TextReplacementConfig
.builder() .builder()
.match(Pattern .match(Pattern
.compile("((https?://(www\\.)?)?[-a-zA-Z0-9@:%._+~#=]" + .compile("((https?://(ww(w|\\d)\\.)?|ww(w|\\d))[-a-zA-Z0-9@:%._+~#=]{1,256}"
"{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_+.~#?&/=]*))")) + "\\.[a-zA-Z0-9]{2,6}\\b([-a-zA-Z0-9@:%_+.~#?&/=]*))"))
.replacement((b, c) -> { .replacement((b, c) -> {
if (c == null) { if (c == null) {
return null; return null;
@ -64,7 +64,7 @@ public final class PlayerChat implements Listener {
final String url; 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 in click events
*/ */
if (content.contains("://")) { if (content.contains("://")) {