-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: closing brace should not be a part of variable #10485
Conversation
please make the ci pass |
done |
apisix/core/utils.lua
Outdated
local v = _ctx[m[1]] | ||
local i = 1 | ||
-- if first capture's first char is "{" evaluate the second capture | ||
if m[1]:byte(1) == 123 then | ||
i = 2 | ||
end | ||
local v = _ctx[m[i]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you add this? we don't need this block to resolve this problem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was to fix other test case failures. For example when var = ${alpha}
, m[1] = {alpha} and m[2] = alpha. Only m[2] can be evaluated no m[1].
apisix/core/utils.lua
Outdated
local v = _ctx[m[1]] | ||
local i = 1 | ||
-- if first capture's first char is "{" evaluate the second capture | ||
if m[1]:byte(1) == 123 then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can optimise this judgement, like
local variable = m[2] or m[3]
local v = _ctx[variable]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it works
Description
Current regex for evaluating variables like:
$var
,${var}
, etc. would also match$var}
including the closing brace. This has been fixed.Fixes #10478
Checklist