File tree Expand file tree Collapse file tree 1 file changed +12
-9
lines changed
src/main/java/org/casbin/jcasbin/util Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,8 @@ public class Util {
3535 public static boolean enableLog = true ;
3636 private static Pattern evalReg = Pattern .compile ("\\ beval\\ (([^),]*)\\ )" );
3737
38+ private static final Pattern IN_SYNTAX_PATTERN = Pattern .compile ("([a-zA-Z0-9_.()\" ]*) +in +([a-zA-Z0-9_.()\" ]*)" );
39+
3840 private static Pattern escapeAssertionRegex = Pattern .compile ("\\ b(r|p)[0-9]*\\ ." );
3941
4042 private static Logger LOGGER = LoggerFactory .getLogger ("org.casbin.jcasbin" );
@@ -144,16 +146,17 @@ public static String escapeAssertion(String s) {
144146 * @return the 'include' expression.
145147 */
146148 public static String convertInSyntax (String expString ) {
147- String reg = "([a-zA-Z0-9_.()\" ]*) +in +([a-zA-Z0-9_.()\" ]*)" ;
148- Matcher m1 = Pattern .compile (reg ).matcher (expString );
149- StringBuffer sb = new StringBuffer ();
150- boolean flag = false ;
151- while (m1 .find ()) {
152- flag = true ;
153- m1 .appendReplacement (sb , "include($2, $1)" );
149+ Matcher matcher = IN_SYNTAX_PATTERN .matcher (expString );
150+ if (matcher .find ()) {
151+ StringBuffer sb = new StringBuffer ();
152+ do {
153+ matcher .appendReplacement (sb , "include($2, $1)" );
154+ } while (matcher .find ());
155+ matcher .appendTail (sb );
156+ return sb .toString ();
154157 }
155- m1 . appendTail ( sb );
156- return flag ? sb . toString () : expString ;
158+
159+ return expString ;
157160 }
158161
159162 /**
You can’t perform that action at this time.
0 commit comments