Skip to content

Commit

Permalink
WFCORE-7083 ModuleNameValidator fails if module name contains a dash
Browse files Browse the repository at this point in the history
  • Loading branch information
pferraro committed Dec 5, 2024
1 parent a62fb1c commit 01b5aac
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
public class ModuleNameValidator extends ModelTypeValidator {
public static final ParameterValidator INSTANCE = new ModuleNameValidator();
// Ensure module name is valid with filesystem module repository, permitting deprecated slot, if present
private static final Predicate<String> MODULE_NAME_TESTER = Pattern.compile("(?:^\\w+|\\w+\\.\\w+|\\w+\\Q\\:\\E\\w+)+(?:\\:(?:\\w+|\\w+\\.\\w+))?$").asMatchPredicate();
private static final Predicate<String> MODULE_NAME_TESTER = Pattern.compile("(?:^\\w+|\\w+[\\.\\-]\\w+|\\w+\\Q\\:\\E\\w+)+(?:\\:(?:\\w+|\\w+[\\.\\-]\\w+))?$").asMatchPredicate();

private ModuleNameValidator() {
super(ModelType.STRING);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public void test() throws OperationFailedException {
validator.validateParameter("valid", new ModelNode("org.jboss.modules:main"));
validator.validateParameter("valid", new ModelNode("org.jboss.modules:1.9"));
validator.validateParameter("escaped", new ModelNode("org.jboss.modules.foo\\:bar:main"));
validator.validateParameter("dash", new ModelNode("org.infinispan.hibernate-cache"));

Assert.assertThrows(OperationFailedException.class, () -> validator.validateParameter("invalid", new ModelNode(".foo.bar")));
Assert.assertThrows(OperationFailedException.class, () -> validator.validateParameter("invalid", new ModelNode("foo..bar")));
Expand Down

0 comments on commit 01b5aac

Please sign in to comment.