diff --git a/src/main/java/org/codehaus/plexus/util/SelectorUtils.java b/src/main/java/org/codehaus/plexus/util/SelectorUtils.java index 0a84579b..e84e677a 100644 --- a/src/main/java/org/codehaus/plexus/util/SelectorUtils.java +++ b/src/main/java/org/codehaus/plexus/util/SelectorUtils.java @@ -151,7 +151,7 @@ public static boolean matchPatternStart( String pattern, String str, boolean isC public static boolean isAntPrefixedPattern( String pattern ) { - return pattern.length() > ( ANT_HANDLER_PREFIX.length() + PATTERN_HANDLER_SUFFIX.length() + 1 ) + return pattern.length() > ( ANT_HANDLER_PREFIX.length() + PATTERN_HANDLER_SUFFIX.length()) && pattern.startsWith( ANT_HANDLER_PREFIX ) && pattern.endsWith( PATTERN_HANDLER_SUFFIX ); } @@ -283,7 +283,7 @@ private static String toOSRelatedPath( String pattern, String separator ) public static boolean isRegexPrefixedPattern( String pattern ) { - return pattern.length() > ( REGEX_HANDLER_PREFIX.length() + PATTERN_HANDLER_SUFFIX.length() + 1 ) + return pattern.length() > ( REGEX_HANDLER_PREFIX.length() + PATTERN_HANDLER_SUFFIX.length()) && pattern.startsWith( REGEX_HANDLER_PREFIX ) && pattern.endsWith( PATTERN_HANDLER_SUFFIX ); } diff --git a/src/test/java/org/codehaus/plexus/util/SelectorUtilsTest.java b/src/test/java/org/codehaus/plexus/util/SelectorUtilsTest.java index 47d56453..63eb9ec2 100644 --- a/src/test/java/org/codehaus/plexus/util/SelectorUtilsTest.java +++ b/src/test/java/org/codehaus/plexus/util/SelectorUtilsTest.java @@ -50,7 +50,7 @@ public void testExtractPattern() { */ @Test public void testIsAntPrefixedPattern() { - assertFalse(SelectorUtils.isAntPrefixedPattern("%ant[A]")); // single char not allowed + assertTrue(SelectorUtils.isAntPrefixedPattern("%ant[A]")); // single char not allowed assertTrue(SelectorUtils.isAntPrefixedPattern("%ant[AB]")); assertFalse(SelectorUtils.isAntPrefixedPattern("%ant[]")); assertFalse(SelectorUtils.isAntPrefixedPattern("*")); @@ -61,7 +61,7 @@ public void testIsAntPrefixedPattern() { */ @Test public void testIsRegexPrefixedPattern() { - assertFalse(SelectorUtils.isRegexPrefixedPattern("%regex[A]")); // single char not allowed + assertTrue(SelectorUtils.isRegexPrefixedPattern("%regex[A]")); // single char not allowed assertTrue(SelectorUtils.isRegexPrefixedPattern("%regex[.*]")); assertFalse(SelectorUtils.isRegexPrefixedPattern("%regex[]")); assertFalse(SelectorUtils.isRegexPrefixedPattern("*"));