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(handler) reverted logic to old one in var.upstream_uri concatenation logic #9269

Merged
merged 1 commit into from
Aug 18, 2022
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
2 changes: 1 addition & 1 deletion kong/runloop/handler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1444,7 +1444,7 @@ return {
if byte(ctx.request_uri or var.request_uri, -1) == QUESTION_MARK then
var.upstream_uri = var.upstream_uri .. "?"
elseif var.is_args == "?" then
var.upstream_uri = var.upstream_uri .. "?" .. var.args or ""
var.upstream_uri = var.upstream_uri .. "?" .. (var.args or "")
end

local upstream_scheme = var.upstream_scheme
Expand Down
29 changes: 28 additions & 1 deletion spec/03-plugins/33-serverless-functions/02-access_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ local mock_fn_nine = [[
error("this should stop the request with a 500")
]]

local mock_fn_ten = [[
ngx.var.args = nil
]]



describe("Plugin: serverless-functions", function()
it("priority of plugins", function()
Expand Down Expand Up @@ -128,6 +133,11 @@ for _, plugin_name in ipairs({ "pre-function", "post-function" }) do
hosts = { "nine." .. plugin_name .. ".com" },
}

local route10 = bp.routes:insert {
service = { id = service.id },
hosts = { "ten." .. plugin_name .. ".com" },
}

bp.plugins:insert {
name = plugin_name,
route = { id = route1.id },
Expand Down Expand Up @@ -176,6 +186,12 @@ for _, plugin_name in ipairs({ "pre-function", "post-function" }) do
config = get_conf { mock_fn_nine },
}

bp.plugins:insert {
name = plugin_name,
route = { id = route10.id },
config = get_conf { mock_fn_ten },
}

assert(helpers.start_kong({
nginx_conf = "spec/fixtures/custom_nginx.template",
}))
Expand Down Expand Up @@ -345,8 +361,19 @@ for _, plugin_name in ipairs({ "pre-function", "post-function" }) do

assert.equal(10, count)
end)
end)


describe("issues", function()
it("does not crash even when query is cleared, #9246", function()
local res = client:get("/status/200?a=b", {
headers = {
["Host"] = "ten." .. plugin_name .. ".com"
}
})
local body = assert.res_status(200, res)
local json = cjson.decode(body)
assert.same({}, json.uri_args)
end)
end)
end)
end
Expand Down