I followed the documentation at https://casbin.apache.org/docs/function and tried to use the keyGet3 function, but discovered that the Java implementation of casbin does not have this function.
After checking the source code, I confirmed that jcasbin only has keyGet and keyGet2 (using :var style), but is missing keyGet3 (using {var} style) which exists in the Go version.
I ported the keyGet3 function from the Go version following the existing code style of keyGet and keyGet2. However, during implementation, I encountered a regex incompatibility issue between Go and Java
where certain valid Go test patterns cause regex compilation errors in Java.
Specifically, patterns like "/{id/using/{resId}" work in Go but fail in Java because Java treats "{" as a repetition quantifier modifier, causing "/{id/using/(" to be interpreted as an invalid quantifier
pattern.
I added extra logic to escape remaining { and } characters after replacement to maintain compatibility with Go's behavior.
Fixes #522
I followed the documentation at https://casbin.apache.org/docs/function and tried to use the keyGet3 function, but discovered that the Java implementation of casbin does not have this function.
After checking the source code, I confirmed that jcasbin only has keyGet and keyGet2 (using
:varstyle), but is missing keyGet3 (using{var}style) which exists in the Go version.I ported the keyGet3 function from the Go version following the existing code style of keyGet and keyGet2. However, during implementation, I encountered a regex incompatibility issue between Go and Java
where certain valid Go test patterns cause regex compilation errors in Java.
Specifically, patterns like "/{id/using/{resId}" work in Go but fail in Java because Java treats "{" as a repetition quantifier modifier, causing "/{id/using/(" to be interpreted as an invalid quantifier
pattern.
I added extra logic to escape remaining
{and}characters after replacement to maintain compatibility with Go's behavior.Fixes #522