This is an automated email from the ASF dual-hosted git repository.
spacewander pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git
The following commit(s) were added to refs/heads/master by this push:
new 4c533ba35 fix: APISIX extended variables cannot be used in
`_meta.filter` (#8256)
4c533ba35 is described below
commit 4c533ba3557acce5e81b4dfab82ac1faa3679dfa
Author: soulbird <[email protected]>
AuthorDate: Mon Nov 7 15:02:28 2022 +0800
fix: APISIX extended variables cannot be used in `_meta.filter` (#8256)
Co-authored-by: soulbird <[email protected]>
Fixes https://github.com/apache/apisix/issues/8251
---
apisix/plugin.lua | 2 +-
t/plugin/plugin.t | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 53 insertions(+), 1 deletion(-)
diff --git a/apisix/plugin.lua b/apisix/plugin.lua
index 090be6629..3207683cf 100644
--- a/apisix/plugin.lua
+++ b/apisix/plugin.lua
@@ -434,7 +434,7 @@ local function meta_filter(ctx, plugin_name, plugin_conf)
" plugin_name: ", plugin_name)
return true
end
- ok, err = ex:eval()
+ ok, err = ex:eval(ctx.var)
if err then
core.log.warn("failed to run the 'vars' expression: ", err,
" plugin_name: ", plugin_name)
diff --git a/t/plugin/plugin.t b/t/plugin/plugin.t
index 42563e89f..28fd81868 100644
--- a/t/plugin/plugin.t
+++ b/t/plugin/plugin.t
@@ -737,3 +737,55 @@ passed
GET /hello
--- response_headers
!x-version
+
+
+
+=== TEST 29: use APISIX's built-in variables in meta.filter
+--- 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 = {
+ ["proxy-rewrite"] = {
+ _meta = {
+ filter = {
+ {"post_arg_key", "==", "abc"}
+ }
+ },
+ uri = "/echo",
+ headers = {
+ ["X-Api-Version"] = "ga"
+ }
+ }
+ },
+ upstream = {
+ nodes = {
+ ["127.0.0.1:1980"] = 1
+ }
+ },
+ uri = "/hello"
+ }
+ )
+ if code >= 300 then
+ ngx.print(body)
+ else
+ ngx.say(body)
+ end
+ }
+ }
+--- response_body
+passed
+
+
+
+=== TEST 30: hit route: proxy-rewrite enable with post_arg_xx in meta.filter
+--- request
+POST /hello
+key=abc
+--- more_headers
+Content-Type: application/x-www-form-urlencoded
+--- response_headers
+x-api-version: ga