Skip to content
This repository has been archived by the owner on Apr 16, 2023. It is now read-only.

Commit

Permalink
Merge pull request #104 from jeakfrw/t/pluginid-validation
Browse files Browse the repository at this point in the history
Lift some sanctions on characters in plugin IDs
  • Loading branch information
MarkL4YG authored Nov 8, 2019
2 parents f383d7a + 5955053 commit e8f1715
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package de.fearnixx.jeak.plugin.persistent;

import de.fearnixx.jeak.Main;
import de.fearnixx.jeak.event.IEvent;
import de.fearnixx.jeak.plugin.PluginContainer;
import de.fearnixx.jeak.reflect.Inject;
Expand All @@ -14,13 +15,17 @@
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.*;
import java.util.regex.Pattern;

/**
* Created by MarkL4YG on 01.06.17.
*/
public class PluginRegistry {

private static final Logger logger = LoggerFactory.getLogger(PluginRegistry.class);
private static final boolean IGNORE_PLUGINID_RESTRICTION =
Main.getProperty("jeak.experimental.skipPluginIdCheck", false);
private static final Pattern PLUGIN_ID_VALIDATON = Pattern.compile("^[a-zA-Z.][a-zA-Z0-9.&+#]+$");

public static Optional<PluginRegistry> getFor(Class<?> pluginClass) {
PluginRegistry pr = new PluginRegistry(pluginClass);
Expand Down Expand Up @@ -53,8 +58,8 @@ protected boolean analyze() {
return false;
}
id = tag.id();
if (!id.matches("^[a-zA-Z.][a-zA-Z.]+$")) {
logger.error("Plugin ID: {} is invalid!", this.id);
if (!IGNORE_PLUGINID_RESTRICTION && !PLUGIN_ID_VALIDATON.matcher(id).matches()) {
logger.error("Plugin ID: {} is invalid! (Must match: {})", this.id, PLUGIN_ID_VALIDATON);
return false;
}
version = Common.stripVersion(tag.version());
Expand Down

0 comments on commit e8f1715

Please sign in to comment.