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

Policy: Routing fix URL encoding. #1208

Merged
merged 1 commit into from
Jun 30, 2020
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Fixed issues with HTTPS_PROXY and large bodies [THREESCALE-3863](https://issues.jboss.org/browse/THREESCALE-3863) [PR #1191](https://github.com/3scale/APIcast/pull/1191)
- Fixed issues with path routing and query args [THREESCALE-5149](https://issues.redhat.com/browse/THREESCALE-5149) [PR #1190](https://github.com/3scale/APIcast/pull/1190)
- Fixed issue with IPCheck policy when forwarder-for value contains port [THREESCALE-5258](https://issues.redhat.com/browse/THREESCALE-5258) [PR #1192](https://github.com/3scale/APIcast/pull/1192)
- Fixed issues with URL encode on routing policy [THREESCALE-5454](https://issues.redhat.com/browse/THREESCALE-5454) [PR #1208](https://github.com/3scale/APIcast/pull/1208)


### Added
Expand Down
3 changes: 1 addition & 2 deletions gateway/src/apicast/upstream.lua
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,8 @@ function _M:rewrite_request()
end

local uri = self.uri

if uri.path then
ngx.req.set_uri(prefix_path(uri.path))
ngx.req.set_uri(ngx.unescape_uri(prefix_path(uri.path)))
end

if uri.query then
Expand Down
69 changes: 69 additions & 0 deletions t/apicast-policy-routing.t
Original file line number Diff line number Diff line change
Expand Up @@ -2125,3 +2125,72 @@ GET /?user_key=value
could not find upstream for service: 42
--- no_error_log
[error]


=== TEST 32: URL is not double encoded.
--- configuration
{
"services": [
{
"id": 42,
"backend_version": 1,
"backend_authentication_type": "service_token",
"backend_authentication_value": "token-value",
"proxy": {
"policy_chain": [
{
"name": "apicast.policy.routing",
"configuration": {
"rules": [
{
"url": "http://test:$TEST_NGINX_SERVER_PORT/second/",
"owner_id": 4,
"condition": {
"operations": [
{
"match": "liquid",
"liquid_value": "test",
"op": "==",
"value": "test"
}
]
}
}
]
}
},
{
"name": "apicast.policy.apicast"
}
],
"proxy_rules": [
{
"pattern": "/foo",
"http_method": "GET",
"metric_system_name": "test",
"delta": 1
}
]
}
}
]
}
--- backend
location /transactions/authrep.xml {
content_by_lua_block {
ngx.say("OK")
}
}
--- upstream
location / {
content_by_lua_block {
ngx.say(ngx.var.uri);
}
}
--- request
GET /foo/test%20space?user_key=foo
--- response_body
/second/foo/test space
--- error_code: 200
--- no_error_log
[error]