update path validation pattern

This commit is contained in:
Mengyi Zhou 2016-08-24 15:55:14 +08:00
parent 2ffa2d8583
commit 3953d61a33
2 changed files with 6 additions and 2 deletions

View file

@ -40,7 +40,7 @@ public class DefaultGroupValidator implements GroupValidator {
private final Set<String> pathPrefixModifier = Sets.newHashSet("=", "~", "~*", "^~");
private final String standardSuffix = "($|/|\\?)";
private final String[] standardSuffixIdentifier = new String[]{"$", "/", "\\?"};
private final Pattern basicPathPath = Pattern.compile("^(\\w+\\/?)+(\\$|\\\\\\?)?");
private final Pattern basicPathPath = Pattern.compile("^(\\w|-)+(\\$|\\\\\\?)?");
@Override
public boolean exists(Long targetId) throws Exception {

View file

@ -107,6 +107,7 @@ public class PathValidationTest extends AbstractServerTest {
String s4 = "members($|/|\\?)|membersite($|/|\\?)";
DefaultGroupValidator tmp = (DefaultGroupValidator) groupModelValidator;
Pattern p = Pattern.compile("^(\\w|-)+(\\$|\\\\\\?)?");
List<String> r;
try {
r = tmp.regexLevelSplit(s1, 1);
@ -114,6 +115,10 @@ public class PathValidationTest extends AbstractServerTest {
Assert.assertEquals("Thingstodo-Order-OrderService$", r.get(0));
Assert.assertEquals("Thingstodo-Order-OrderService/", r.get(1));
Assert.assertEquals("Thingstodo-Order-OrderService\\?", r.get(2));
Assert.assertTrue(p.matcher(r.get(0)).matches());
Assert.assertTrue(p.matcher(r.get(1)).matches());
Assert.assertTrue(p.matcher(r.get(2)).matches());
} catch (ValidationException e) {
Assert.assertTrue(false);
}
@ -121,7 +126,6 @@ public class PathValidationTest extends AbstractServerTest {
try {
r = tmp.regexLevelSplit(s2, 1);
Assert.assertEquals(6, r.size());
Pattern p = Pattern.compile("^\\w+($|/|\\?)?");
Assert.assertFalse(p.matcher(r.get(0)).matches());
Assert.assertFalse(p.matcher(r.get(1)).matches());
} catch (ValidationException e) {