mirror of
https://github.com/ctripcorp/zeus.git
synced 2024-09-20 15:46:01 +08:00
update path validation pattern
This commit is contained in:
parent
2ffa2d8583
commit
3953d61a33
|
@ -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 {
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue