Closed ptmarquis closed 1 year ago
One way to fix this is to specify a Locale in the call to String#format
when creating the regular expression. Diff below
diff --git a/src/main/java/org/passay/RepeatCharacterRegexRule.java b/src/main/java/org/passay/RepeatCharacterRegexRule.java
index c0b89e4..4250d39 100644
--- a/src/main/java/org/passay/RepeatCharacterRegexRule.java
+++ b/src/main/java/org/passay/RepeatCharacterRegexRule.java
@@ -1,6 +1,8 @@
/* See LICENSE for licensing and NOTICE for copyright. */
package org.passay;
+import java.util.Locale;
+
/**
* Rule for determining if a password contains a duplicate ASCII keyboard sequence. See {@link java.util.regex.Pattern}
* /p{ASCII}. The default sequence length is 5 characters.
@@ -53,7 +55,7 @@ public class RepeatCharacterRegexRule extends IllegalRegexRule
*/
public RepeatCharacterRegexRule(final int sl, final boolean reportAll)
{
- super(String.format(REPEAT_CHAR_REGEX, sl - 1), reportAll);
+ super(String.format(Locale.ENGLISH, REPEAT_CHAR_REGEX, sl - 1), reportAll);
if (sl < MINIMUM_SEQUENCE_LENGTH) {
throw new IllegalArgumentException(String.format("sequence length must be >= %s", MINIMUM_SEQUENCE_LENGTH));
}
Thanks for fixing this so quickly!
Creating an instance of RepeatCharacterRegexRule will generate an exception in certain Locale's. The regular expression used internally by the class will include a repetition count that is non-ASCII. Below is a TestNG test case demonstrating the issue
Stack trace