You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm seeing an issue where values for config.replace.json in the response-transformer plugin are showing up with doubly encoded slashes. This is an issue for me because I'm using kong with path based routing to serve swagger documents that need to have their basePath transformed to match the paths from which the APIs are being served.
Kong version: 0.7.0
Platform: Docker container
Use Case
What is being served by the underlying / backing service:
{
"swagger": 2.0,
"basePath": "/",
...
}
What I'd like kong to return by configuring the response-transformer:
-- replace key:value to body
for _, name, value in iter(conf.replace.json) do
local v = cjson.encode(value)
if stringy.startswith(v, "\"") and stringy.endswith(v, "\"") then
v = v:sub(2, v:len() - 1):gsub("\\\"", "\"") -- To prevent having double encoded quotes
end
-- BEGIN PATCH
-- Correct double encoding of forward slashes
v = v:gsub("\\/", "/")
-- END PATCH
if json_body[name] then
json_body[name] = v
end
end
I'd be curious to know if anyone else has run into this and if so how they solved it. If you can repro the issue and think the approach taken in the patch is viable, I can work on a PR for all of the config.json.* methods to make sure that forward slashes are handled appropriately.
The text was updated successfully, but these errors were encountered:
Overview
I'm seeing an issue where values for config.replace.json in the response-transformer plugin are showing up with doubly encoded slashes. This is an issue for me because I'm using kong with path based routing to serve swagger documents that need to have their
basePath
transformed to match the paths from which the APIs are being served.Kong version: 0.7.0
Platform: Docker container
Use Case
What is being served by the underlying / backing service:
What I'd like kong to return by configuring the response-transformer:
What I'm actually seeing:
Steps to Reproduce
How I patched this
Patched from https://github.com/Mashape/kong/blob/0.7.0/kong/plugins/response-transformer/body_transformer.lua#L59
I'd be curious to know if anyone else has run into this and if so how they solved it. If you can repro the issue and think the approach taken in the patch is viable, I can work on a PR for all of the config.json.* methods to make sure that forward slashes are handled appropriately.
The text was updated successfully, but these errors were encountered: