Skip to content
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

Merged
merged 6 commits into from
Nov 24, 2023

Conversation

shreemaan-abhishek
Copy link
Contributor

@shreemaan-abhishek shreemaan-abhishek commented Nov 13, 2023

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

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

@shreemaan-abhishek shreemaan-abhishek marked this pull request as draft November 14, 2023 01:02
@shreemaan-abhishek shreemaan-abhishek marked this pull request as ready for review November 14, 2023 03:12
@monkeyDluffy6017
Copy link
Contributor

please make the ci pass

@shreemaan-abhishek
Copy link
Contributor Author

done

Comment on lines 299 to 304
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]]
Copy link
Contributor

@monkeyDluffy6017 monkeyDluffy6017 Nov 14, 2023

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

Copy link
Contributor Author

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].

@monkeyDluffy6017 monkeyDluffy6017 added the wait for update wait for the author's response in this issue/PR label Nov 14, 2023
@shreemaan-abhishek shreemaan-abhishek removed the wait for update wait for the author's response in this issue/PR label Nov 15, 2023
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
Copy link
Contributor

@monkeyDluffy6017 monkeyDluffy6017 Nov 20, 2023

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]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it works

@monkeyDluffy6017 monkeyDluffy6017 added the wait for update wait for the author's response in this issue/PR label Nov 21, 2023
@monkeyDluffy6017 monkeyDluffy6017 added approved and removed wait for update wait for the author's response in this issue/PR labels Nov 22, 2023
@monkeyDluffy6017 monkeyDluffy6017 merged commit 1437b60 into apache:master Nov 24, 2023
32 of 33 checks passed
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: incorrect variable extraction in the configuration
5 participants