File tree 2 files changed +11
-2
lines changed
2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -404,6 +404,7 @@ function CoreEnforcer:enforceEx(...)
404
404
end
405
405
406
406
local expString = self .model .model [" m" ][" m" ].value
407
+ local hasEval = Util .hasEval (expString )
407
408
408
409
local policyLen = # self .model .model [" p" ][" p" ].policy
409
410
@@ -429,8 +430,11 @@ function CoreEnforcer:enforceEx(...)
429
430
context [v ] = pvals [k ]
430
431
end
431
432
432
- local tExpString = Util .findAndReplaceEval (expString , context )
433
-
433
+ local tExpString = expString
434
+ if hasEval then
435
+ tExpString = Util .findAndReplaceEval (expString , context )
436
+ end
437
+
434
438
local res , err
435
439
if tExpString == expString then
436
440
res , err = luaxp .run (compiledExpression , context )
Original file line number Diff line number Diff line change @@ -166,6 +166,11 @@ function Util.areTablesSame(a, b)
166
166
return true
167
167
end
168
168
169
+ -- checks if the matcher string has eval(...)
170
+ function Util .hasEval (str )
171
+ return string.find (str , " eval%((.-)%)" )
172
+ end
173
+
169
174
-- finds if string has eval and replaces eval(...) with its value so that it can be evaluated by luaxp
170
175
function Util .findAndReplaceEval (str , context )
171
176
local m = string.gsub (str , " eval%((.-)%)" , function (s )
You can’t perform that action at this time.
0 commit comments