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: body-transformer - failed to transform response body - XML #11672

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
33 changes: 21 additions & 12 deletions apisix/plugins/body-transformer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,23 +78,32 @@ end


local function remove_namespace(tbl)
for k, v in pairs(tbl) do
if type(v) == "table" and next(v) == nil then

local function update_namespace(ns)
local v = ns
if type(ns) == "table" and next(ns) == nil then
v = ""
tbl[k] = v
elseif type(ns) == "table" then
v = remove_namespace(ns)
end
if type(k) == "string" then
local newk = k:match(".*:(.*)")
if newk then
tbl[newk] = v
tbl[k] = nil
end
if type(v) == "table" then
remove_namespace(v)
return v
end

local function remove_namespace_wrapper(old_table, new_table)
for k, v in pairs(old_table) do
if type(k) == "string" then
local newk = k:match(".*:(.*)")
if newk then
new_table[newk] = update_namespace(v)
else
new_table[k] = update_namespace(v)
end
end
end
return new_table
end
return tbl

return remove_namespace_wrapper(tbl, {})
end


Expand Down
Loading