Repository: casbin/jcasbin (Java)

Issue:
[bug] || replaced with comma in policy fields
The project I'm working on stores groovy code in one of the policy fields and some of the policies happen to use `||` operator.
Recent versions of `jcasbin` after loading policies end up with the operator replaced with a comma - this modification breaks the function we have in place which expects to evaluate the value of the field a  groovy code and reports `Script.groovy: 1: Unexpected input: ',' @ line 1...`

The bug was introduced by [PR #408](https://github.com/casbin/jcasbin/pull/408) which was an attempt to fix [issue #407](https://github.com/casbin/jcasbin/issues/407). The real cause of `issue #407`, however, was in `casbin/jdbc-adapter` which didn't escape policy field values read in from the database before parsing the data as a CSV line - this was fixed by [PR #74](https://github.com/jcasbin/jdbc-adapter/pull/74) which ended up in publicly available release of `jdbc-adapter` version `2.10.0`. 

`Issue #407` does not require changes introduced by `PR #408` and as those changes bring in a separate bug (at least in some cases), I'd like to ask for `PR #408` be reverted and a new version be released.


Discussion:
 @tangyang9464 @imp2002
:tada: This issue has been resolved in version 1.68.0 :tada:

The release is available on:
- [GitHub release](https://github.com/casbin/jcasbin/releases/tag/v1.68.0)
- `v1.68.0`

Your **[semantic-release](https://github.com/semantic-release/semantic-release)** bot :package::rocket:



Patch:
diff --git a/src/main/java/org/casbin/jcasbin/util/Util.java b/src/main/java/org/casbin/jcasbin/util/Util.java
index 64838226..d27923b5 100644
--- a/src/main/java/org/casbin/jcasbin/util/Util.java
+++ b/src/main/java/org/casbin/jcasbin/util/Util.java
@@ -35,16 +35,12 @@ public class Util {
     public static boolean enableLog = true;
     private static Pattern evalReg = Pattern.compile("\\beval\\(([^),]*)\\)");
 
-    private static Pattern BracketsReg = Pattern.compile("\\{[^}]*\\}");
-
     private static Pattern escapeAssertionRegex = Pattern.compile("\\b(r|p)[0-9]*\\.");
 
     private static Logger LOGGER = LoggerFactory.getLogger("org.casbin.jcasbin");
 
     private static final String md5AlgorithmName = "MD5";
 
-    private static final String MEDIAN = "||";
-
     /**
      * logPrint prints the log.
      *
@@ -274,13 +270,12 @@ public static String[] splitCommaDelimited(String s) {
         String[] records = null;
         if (s != null) {
             try {
-                s = replaceCommaInBrackets(s);
                 CSVFormat csvFormat = CSVFormat.Builder.create().setIgnoreSurroundingSpaces(true).build();
                 CSVParser csvParser = csvFormat.parse(new StringReader(s));
                 List<CSVRecord> csvRecords = csvParser.getRecords();
                 records = new String[csvRecords.get(0).size()];
                 for (int i = 0; i < csvRecords.get(0).size(); i++) {
-                    records[i] = csvRecords.get(0).get(i).replace(MEDIAN, ",").trim();
+                    records[i] = csvRecords.get(0).get(i).trim();
                 }
             } catch (IOException e) {
                 Util.logPrintfError("CSV parser failed to parse this line: " + s, e);
@@ -318,18 +313,6 @@ public static boolean setEquals(List<String> a, List<String> b) {
         return true;
     }
 
-    public static String replaceCommaInBrackets(String s){
-        Matcher matcher = BracketsReg.matcher(s);
-        StringBuffer sb = new StringBuffer();
-        while (matcher.find()) {
-            String match = matcher.group();
-            String replaced = match.replaceAll(",", MEDIAN);
-            matcher.appendReplacement(sb, replaced);
-        }
-        matcher.appendTail(sb);
-        return sb.length() > 0 ? sb.toString() : s;
-    }
-
     public static boolean hasEval(String exp) {
         return evalReg.matcher(exp).matches();
     }


Test patch:
diff --git a/src/test/java/org/casbin/jcasbin/main/UtilTest.java b/src/test/java/org/casbin/jcasbin/main/UtilTest.java
index 1a89c976..545bc373 100644
--- a/src/test/java/org/casbin/jcasbin/main/UtilTest.java
+++ b/src/test/java/org/casbin/jcasbin/main/UtilTest.java
@@ -111,12 +111,9 @@ public void should_logged_when_splitCommaDelimited_given_ioException() {
             MockedConstruction<CSVFormat> stringReaderMocked = BDDMockito.mockConstruction(CSVFormat.class, (mock, context) -> {
                 BDDMockito.given(mock.parse(any(StringReader.class))).willThrow(ioEx);
             })) {
-
-            String csv = "\n";
-
             // given
-            utilMocked.when(() -> Util.replaceCommaInBrackets(anyString())).thenReturn(csv);
             utilMocked.when(() -> Util.splitCommaDelimited(anyString())).thenCallRealMethod();
+            String csv = "\n";
 
             // when
             Util.splitCommaDelimited(csv);