casbin4d / Casbin4D

An authorization library that supports access control models like ACL, RBAC, ABAC in Delphi
https://casbin.org
Apache License 2.0
44 stars 16 forks source link

TMatcher.replaceIdentifiers: Replace only the key if it is an 100% match #16

Closed ErikUniformAgri closed 2 years ago

ErikUniformAgri commented 2 years ago

See example in code

hsluoyz commented 2 years ago

@jkour plz review

jkour commented 2 years ago

Hi again,

Can you please explain what is the need for this?

Can a test show the difference?

ErikUniformAgri commented 2 years ago

I have added an testcase which gives an error in the original code, but does not in the new code. I only expected a Deny, but it gets accepted somehow. Do you know why? And if thats correct?

hsluoyz commented 2 years ago

@jkour

jkour commented 2 years ago

Hi, The RegExpression you added does not replace all the instances of the pair.key. It replaces only the first instance.

jkour commented 2 years ago

Actually, the pattern grabs the xxxx= but not the =xxx. You write it your comments

ErikUniformAgri commented 2 years ago

All identifiers are replaced now. As far as I can see the pattern grabs the right part in the string.

jkour commented 2 years ago

Great. This looks good. Thx