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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions apisix/core/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,13 @@ local resolve_var
do
local _ctx
local n_resolved
local pat = [[(?<!\\)\$\{?(\w+)\}?]]
local pat = [[(?<!\\)\$(\{(\w+)\}|(\w+))]]
local _escaper

local function resolve(m)
local v = _ctx[m[1]]
local variable = m[2] or m[3]
local v = _ctx[variable]

if v == nil then
return ""
end
Expand Down
44 changes: 44 additions & 0 deletions t/plugin/fault-injection2.t
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,47 @@ GET /hello
h1: v1
h2: 2
h3: /hello



=== TEST 6: closing curly brace not should not be a part of variable
--- config
location /t {
content_by_lua_block {
local t = require("lib.test_admin").test
local code, body = t('/apisix/admin/routes/1',
ngx.HTTP_PUT,
[=[{
"plugins": {
"fault-injection": {
"abort": {
"http_status": 200,
"body": "{\"count\": $arg_count}"
}
}
},
"upstream": {
"nodes": {
"127.0.0.1:1980": 1
},
"type": "roundrobin"
},
"uri": "/hello"
}]=]
)
if code >= 300 then
ngx.status = code
end
ngx.say(body)
}
}
--- response_body
passed



=== TEST 7: test route
--- request
GET /hello?count=2
--- response_body chomp
{"count": 2}
Loading