Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/src/main/java/org/geysermc/geyser/GeyserImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public class GeyserImpl implements GeyserApi, EventRegistrar {
*/
public static final String OAUTH_CLIENT_ID = "204cefd1-4818-4de1-b98d-513fae875d88";

private static final String IP_REGEX = "\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b";
private static final Pattern IP_REGEX = Pattern.compile("\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b");

private final SessionManager sessionManager = new SessionManager();

Expand Down Expand Up @@ -406,7 +406,7 @@ private void startInstance() {

String remoteAddress = config.getRemote().address();
// Filters whether it is not an IP address or localhost, because otherwise it is not possible to find out an SRV entry.
if (!remoteAddress.matches(IP_REGEX) && !remoteAddress.equalsIgnoreCase("localhost")) {
if (!IP_REGEX.matcher(remoteAddress).matches() && !remoteAddress.equalsIgnoreCase("localhost")) {
String[] record = WebUtils.findSrvRecord(this, remoteAddress);
if (record != null) {
int remotePort = Integer.parseInt(record[2]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@

@RequiredArgsConstructor
public class GeyserExtensionLoader extends ExtensionLoader {
private static final Pattern[] EXTENSION_FILTERS = new Pattern[] { Pattern.compile("^.+\\.jar$") };
private static final Pattern EXTENSION_FILTER = Pattern.compile("^.+\\.jar$");

private final Object2ObjectMap<String, Class<?>> classes = new Object2ObjectOpenHashMap<>();
private final Map<String, GeyserExtensionClassLoader> classLoaders = new HashMap<>();
Expand Down Expand Up @@ -133,8 +133,8 @@ public GeyserExtensionDescription extensionDescription(Path path) throws Invalid
}
}

public Pattern[] extensionFilters() {
return EXTENSION_FILTERS;
public Pattern extensionFilter() {
return EXTENSION_FILTER;
}

public Class<?> classByName(final String name) throws ClassNotFoundException{
Expand Down Expand Up @@ -249,17 +249,15 @@ protected void loadAllExtensions(@NonNull ExtensionManager extensionManager) {
*/
private void processExtensionsFolder(Path directory, ThrowingBiConsumer<Path, GeyserExtensionDescription> accept, BiConsumer<Path, Throwable> reject) throws IOException {
List<Path> extensionPaths = Files.list(directory).toList();
Pattern[] extensionFilters = this.extensionFilters();
Pattern extensionFilter = this.extensionFilter();
extensionPaths.forEach(path -> {
if (Files.isDirectory(path)) {
return;
}

// Only look at files that meet the extension filter
for (Pattern filter : extensionFilters) {
if (!filter.matcher(path.getFileName().toString()).matches()) {
return;
}
if (!extensionFilter.matcher(path.getFileName().toString()).matches()) {
return;
}

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,12 @@
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.function.Function;
import java.util.regex.Pattern;

public class CustomSkullRegistryPopulator {

private static final Pattern SKULL_HASH_PATTERN = Pattern.compile("^[a-fA-F0-9]{64}$");

public static void populate() {
SkullResourcePackManager.SKULL_SKINS.clear(); // Remove skins after reloading
BlockRegistries.CUSTOM_SKULLS.set(Object2ObjectMaps.emptyMap());
Expand Down Expand Up @@ -117,7 +120,7 @@ public void register(@NonNull String texture, @NonNull SkullTextureType type) {
});

skinHashes.forEach((skinHash) -> {
if (!skinHash.matches("^[a-fA-F0-9]+$")) {
if (!SKULL_HASH_PATTERN.matcher(skinHash).matches()) {
GeyserImpl.getInstance().getLogger().error("Skin hash " + skinHash + " does not match required format ^[a-fA-F0-9]{64}$ and will not be added as a custom block.");
return;
}
Expand Down