File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
src/main/java/org/casbin/adapter Expand file tree Collapse file tree 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 {
179179 }
180180
181181 protected void loadPolicyLine (CasbinRule line , Model model ) {
182+ escapeCasbinRule (line );
182183 String lineText = line .ptype ;
183184 if (!"" .equals (line .v0 )) {
184185 lineText += ", " + line .v0 ;
@@ -540,4 +541,20 @@ protected void retry(ExecutionContext<Void> ctx) throws SQLException {
540541 protected String renderActualSql (String sql ) {
541542 return sql .replace (DEFAULT_TABLE_NAME , tableName );
542543 }
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+ }
543560}
You can’t perform that action at this time.
0 commit comments