This is an automated email from the ASF dual-hosted git repository. membphis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-apisix.git
The following commit(s) were added to refs/heads/master by this push: new 70ff4a5 plugin(proxy-rewrite): using schema pattern to check if uri option starts with / in proxy-rewrite plugin. (#1041) 70ff4a5 is described below commit 70ff4a556d3b0c37c196ce3e3a672b34cd188a59 Author: agile6v <agil...@agile6v.com> AuthorDate: Sun Jan 12 16:35:05 2020 +0800 plugin(proxy-rewrite): using schema pattern to check if uri option starts with / in proxy-rewrite plugin. (#1041) --- lua/apisix/plugin.lua | 2 +- lua/apisix/plugins/proxy-rewrite.lua | 10 ++-------- t/plugin/proxy-rewrite.t | 2 +- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/lua/apisix/plugin.lua b/lua/apisix/plugin.lua index 969ecb1..0a6b17a 100644 --- a/lua/apisix/plugin.lua +++ b/lua/apisix/plugin.lua @@ -138,7 +138,7 @@ local function load_stream() local plugin_names = local_conf.stream_plugins if not plugin_names then - core.log.warn("failed to read stream plugin list form local file") + core.log.warn("failed to read stream plugin list from local file") return true end diff --git a/lua/apisix/plugins/proxy-rewrite.lua b/lua/apisix/plugins/proxy-rewrite.lua index ab0e593..cc1af62 100644 --- a/lua/apisix/plugins/proxy-rewrite.lua +++ b/lua/apisix/plugins/proxy-rewrite.lua @@ -21,7 +21,6 @@ local ipairs = ipairs local ngx = ngx local type = type local re_sub = ngx.re.sub -local str_sub = string.sub local schema = { @@ -31,7 +30,8 @@ local schema = { description = "new uri for upstream", type = "string", minLength = 1, - maxLength = 4096 + maxLength = 4096, + pattern = "^/.*", }, regex_uri = { description = "new uri that substitute from client uri " .. @@ -92,12 +92,6 @@ function _M.check_schema(conf) end end - if conf.uri ~= nil then - if str_sub(conf.uri, 1, 1) ~= "/" then - return false, "invalid uri(" .. conf.uri .. "), must start with /." - end - end - --reform header from object into array, so can avoid use pairs, which is NYI if conf.headers then conf.headers_arr = {} diff --git a/t/plugin/proxy-rewrite.t b/t/plugin/proxy-rewrite.t index 832a197..f7e7afd 100644 --- a/t/plugin/proxy-rewrite.t +++ b/t/plugin/proxy-rewrite.t @@ -1003,6 +1003,6 @@ invalid capturing variable name found GET /t --- error_code: 400 --- response_body eval -qr/invalid uri/ +qr/failed to match pattern/ --- no_error_log [error]