Skip to content

Commit 89b4c56

Browse files
authored
feat: Revert "feat: fix the comma separater bug" (casbin#431)
This reverts commit bab3550.
1 parent f49fddb commit 89b4c56

File tree

2 files changed

+2
-22
lines changed

2 files changed

+2
-22
lines changed

src/main/java/org/casbin/jcasbin/util/Util.java

+1-18
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,12 @@ public class Util {
3535
public static boolean enableLog = true;
3636
private static Pattern evalReg = Pattern.compile("\\beval\\(([^),]*)\\)");
3737

38-
private static Pattern BracketsReg = Pattern.compile("\\{[^}]*\\}");
39-
4038
private static Pattern escapeAssertionRegex = Pattern.compile("\\b(r|p)[0-9]*\\.");
4139

4240
private static Logger LOGGER = LoggerFactory.getLogger("org.casbin.jcasbin");
4341

4442
private static final String md5AlgorithmName = "MD5";
4543

46-
private static final String MEDIAN = "||";
47-
4844
/**
4945
* logPrint prints the log.
5046
*
@@ -274,13 +270,12 @@ public static String[] splitCommaDelimited(String s) {
274270
String[] records = null;
275271
if (s != null) {
276272
try {
277-
s = replaceCommaInBrackets(s);
278273
CSVFormat csvFormat = CSVFormat.Builder.create().setIgnoreSurroundingSpaces(true).build();
279274
CSVParser csvParser = csvFormat.parse(new StringReader(s));
280275
List<CSVRecord> csvRecords = csvParser.getRecords();
281276
records = new String[csvRecords.get(0).size()];
282277
for (int i = 0; i < csvRecords.get(0).size(); i++) {
283-
records[i] = csvRecords.get(0).get(i).replace(MEDIAN, ",").trim();
278+
records[i] = csvRecords.get(0).get(i).trim();
284279
}
285280
} catch (IOException e) {
286281
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) {
318313
return true;
319314
}
320315

321-
public static String replaceCommaInBrackets(String s){
322-
Matcher matcher = BracketsReg.matcher(s);
323-
StringBuffer sb = new StringBuffer();
324-
while (matcher.find()) {
325-
String match = matcher.group();
326-
String replaced = match.replaceAll(",", MEDIAN);
327-
matcher.appendReplacement(sb, replaced);
328-
}
329-
matcher.appendTail(sb);
330-
return sb.length() > 0 ? sb.toString() : s;
331-
}
332-
333316
public static boolean hasEval(String exp) {
334317
return evalReg.matcher(exp).matches();
335318
}

src/test/java/org/casbin/jcasbin/main/UtilTest.java

+1-4
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,9 @@ public void should_logged_when_splitCommaDelimited_given_ioException() {
111111
MockedConstruction<CSVFormat> stringReaderMocked = BDDMockito.mockConstruction(CSVFormat.class, (mock, context) -> {
112112
BDDMockito.given(mock.parse(any(StringReader.class))).willThrow(ioEx);
113113
})) {
114-
115-
String csv = "\n";
116-
117114
// given
118-
utilMocked.when(() -> Util.replaceCommaInBrackets(anyString())).thenReturn(csv);
119115
utilMocked.when(() -> Util.splitCommaDelimited(anyString())).thenCallRealMethod();
116+
String csv = "\n";
120117

121118
// when
122119
Util.splitCommaDelimited(csv);

0 commit comments

Comments
 (0)