File tree 1 file changed +17
-0
lines changed
src/main/java/org/casbin/adapter
1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -179,6 +179,7 @@ protected void migrate() throws SQLException {
179
179
}
180
180
181
181
protected void loadPolicyLine (CasbinRule line , Model model ) {
182
+ escapeCasbinRule (line );
182
183
String lineText = line .ptype ;
183
184
if (!"" .equals (line .v0 )) {
184
185
lineText += ", " + line .v0 ;
@@ -540,4 +541,20 @@ protected void retry(ExecutionContext<Void> ctx) throws SQLException {
540
541
protected String renderActualSql (String sql ) {
541
542
return sql .replace (DEFAULT_TABLE_NAME , tableName );
542
543
}
544
+
545
+ private void escapeCasbinRule (CasbinRule line ) {
546
+ line .v0 = escapeSingleRule (line .v0 );
547
+ line .v1 = escapeSingleRule (line .v1 );
548
+ line .v2 = escapeSingleRule (line .v2 );
549
+ line .v3 = escapeSingleRule (line .v3 );
550
+ line .v4 = escapeSingleRule (line .v4 );
551
+ line .v5 = escapeSingleRule (line .v5 );
552
+ }
553
+
554
+ private String escapeSingleRule (String rule ) {
555
+ if (rule .isEmpty () || (rule .startsWith ("\" " ) && rule .endsWith ("\" " ))) {
556
+ return rule ;
557
+ }
558
+ return String .format ("\" %s\" " , rule );
559
+ }
543
560
}
You can’t perform that action at this time.
0 commit comments