Fix: double slashes in redirect URL#2998
Merged
zirain merged 23 commits intoenvoyproxy:mainfrom Mar 29, 2024
Merged
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2998 +/- ##
==========================================
+ Coverage 64.56% 64.58% +0.02%
==========================================
Files 121 121
Lines 21369 21382 +13
==========================================
+ Hits 13796 13809 +13
Misses 6707 6707
Partials 866 866 ☔ View full report in Codecov by Sentry. |
7799df0 to
a11cd5e
Compare
Signed-off-by: huabing zhao <zhaohuabing@gmail.com>
a11cd5e to
c0b619c
Compare
Signed-off-by: huabing zhao <zhaohuabing@gmail.com>
982eecb to
76cc1c9
Compare
Signed-off-by: huabing zhao <zhaohuabing@gmail.com>
Contributor
|
hey @zhaohuabing I found some code under URLRewrite, gateway/internal/xds/translator/route.go Line 332 in 485edbe |
zirain
reviewed
Mar 26, 2024
24f7643 to
3994460
Compare
Signed-off-by: huabing zhao <zhaohuabing@gmail.com>
Signed-off-by: huabing zhao <zhaohuabing@gmail.com>
Signed-off-by: huabing zhao <zhaohuabing@gmail.com>
Signed-off-by: huabing zhao <zhaohuabing@gmail.com>
Signed-off-by: huabing zhao <zhaohuabing@gmail.com>
arkodg
reviewed
Mar 28, 2024
internal/xds/translator/route.go
Outdated
| func useRegexRewriteForPrefixMatchReplace(pathMatch *ir.StringMatch, prefixMatchReplace string) bool { | ||
| return pathMatch != nil && | ||
| pathMatch.Prefix != nil && | ||
| *pathMatch.Prefix != "/" && |
Member
Author
There was a problem hiding this comment.
It's an edge case. We don't need to use prefixMatchReplace if the patchMatch prefix is "/". But regex still work anyway. I removed this line.
virtual_hosts:
- name: service
domains:
- "*"
routes:
- match:
prefix: "/"
redirect:
prefixRewrite: "/"
Contributor
|
looks good, thanks for reusing the existing code ! |
Signed-off-by: huabing zhao <zhaohuabing@gmail.com>
arkodg
approved these changes
Mar 29, 2024
Contributor
arkodg
left a comment
There was a problem hiding this comment.
LGTM thanks for fixing this quirk !
and also adding e2es 🚀
zirain
approved these changes
Mar 29, 2024
arkodg
pushed a commit
to arkodg/gateway
that referenced
this pull request
Apr 8, 2024
* fix: double trailing splashs in redirect URL Signed-off-by: huabing zhao <zhaohuabing@gmail.com> * add e2e tests Signed-off-by: huabing zhao <zhaohuabing@gmail.com> * fix lint Signed-off-by: huabing zhao <zhaohuabing@gmail.com> * fix test Signed-off-by: huabing zhao <zhaohuabing@gmail.com> * fix test Signed-off-by: huabing zhao <zhaohuabing@gmail.com> * fix test Signed-off-by: huabing zhao <zhaohuabing@gmail.com> * fix test Signed-off-by: huabing zhao <zhaohuabing@gmail.com> * add e2e tests Signed-off-by: huabing zhao <zhaohuabing@gmail.com> * fix test Signed-off-by: huabing zhao <zhaohuabing@gmail.com> * revert Signed-off-by: huabing zhao <zhaohuabing@gmail.com> * use regex rewrite to generate the redirect url Signed-off-by: huabing zhao <zhaohuabing@gmail.com> * use regex rewrite to generate the redirect url Signed-off-by: huabing zhao <zhaohuabing@gmail.com> * use regex rewrite to generate the redirect url Signed-off-by: huabing zhao <zhaohuabing@gmail.com> * remove comments Signed-off-by: huabing zhao <zhaohuabing@gmail.com> * extract method Signed-off-by: huabing zhao <zhaohuabing@gmail.com> * address comments Signed-off-by: huabing zhao <zhaohuabing@gmail.com> --------- Signed-off-by: huabing zhao <zhaohuabing@gmail.com> (cherry picked from commit ceb697f) Signed-off-by: Arko Dasgupta <arko@tetrate.io>
Xunzhuo
added a commit
that referenced
this pull request
Apr 8, 2024
* Run certgen when upgrading (#2934) run certgen when upgrading Signed-off-by: huabing zhao <zhaohuabing@gmail.com> (cherry picked from commit 62ecf15) Signed-off-by: Arko Dasgupta <arko@tetrate.io> * Fix: nil secret in resourceversiontable (#2982) * fix nil secret in resourceversiontable Signed-off-by: huabing zhao <zhaohuabing@gmail.com> * check secrets in the xds result Signed-off-by: huabing zhao <zhaohuabing@gmail.com> --------- Signed-off-by: huabing zhao <zhaohuabing@gmail.com> (cherry picked from commit e880439) Signed-off-by: Arko Dasgupta <arko@tetrate.io> * fix: add missing http filters to the http filter chain (#2970) * fix: add missing http filters to the http filter chain Signed-off-by: huabing zhao <zhaohuabing@gmail.com> * refactor Signed-off-by: huabing zhao <zhaohuabing@gmail.com> * fix lint Signed-off-by: huabing zhao <zhaohuabing@gmail.com> * add comments Signed-off-by: huabing zhao <zhaohuabing@gmail.com> * remove refactor Signed-off-by: huabing zhao <zhaohuabing@gmail.com> * remove refactor Signed-off-by: huabing zhao <zhaohuabing@gmail.com> * fix gen Signed-off-by: huabing zhao <zhaohuabing@gmail.com> * fix lint Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> --------- Signed-off-by: huabing zhao <zhaohuabing@gmail.com> Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> (cherry picked from commit f699edf) Signed-off-by: Arko Dasgupta <arko@tetrate.io> * fix: allow websockets in url rewrite (#3022) allow websockets in url rewrite Signed-off-by: Jesse Haka <haka.jesse@gmail.com> Co-authored-by: zirain <zirain2009@gmail.com> (cherry picked from commit 3d51933) Signed-off-by: Arko Dasgupta <arko@tetrate.io> * Set host for http health checker explicitly to avoid using the cluster name as host header for http health checking request. (#3057) * Set host for http health checker explictly to avoid using the cluster name as host header for http health checking request Signed-off-by: lemonlinger <lemonlinger@gmail.com> * fix broken tests Signed-off-by: lemonlinger <lemonlinger@gmail.com> * fix health-check test case in xds translation Signed-off-by: lemonlinger <lemonlinger@gmail.com> * Simplify code and concise comments Signed-off-by: lemonlinger <lemonlinger@gmail.com> --------- Signed-off-by: lemonlinger <lemonlinger@gmail.com> (cherry picked from commit 8f450a9) Signed-off-by: Arko Dasgupta <arko@tetrate.io> * fix: do not create infra resources when missing translated listeners (#3043) * fix: do not create infra resources when missing translated listeners Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> * remove empty line Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> * skip infra creation on empty listeners and log it Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> --------- Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> (cherry picked from commit 36d7141) Signed-off-by: Arko Dasgupta <arko@tetrate.io> * Fix: double slashes in redirect URL (#2998) * fix: double trailing splashs in redirect URL Signed-off-by: huabing zhao <zhaohuabing@gmail.com> * add e2e tests Signed-off-by: huabing zhao <zhaohuabing@gmail.com> * fix lint Signed-off-by: huabing zhao <zhaohuabing@gmail.com> * fix test Signed-off-by: huabing zhao <zhaohuabing@gmail.com> * fix test Signed-off-by: huabing zhao <zhaohuabing@gmail.com> * fix test Signed-off-by: huabing zhao <zhaohuabing@gmail.com> * fix test Signed-off-by: huabing zhao <zhaohuabing@gmail.com> * add e2e tests Signed-off-by: huabing zhao <zhaohuabing@gmail.com> * fix test Signed-off-by: huabing zhao <zhaohuabing@gmail.com> * revert Signed-off-by: huabing zhao <zhaohuabing@gmail.com> * use regex rewrite to generate the redirect url Signed-off-by: huabing zhao <zhaohuabing@gmail.com> * use regex rewrite to generate the redirect url Signed-off-by: huabing zhao <zhaohuabing@gmail.com> * use regex rewrite to generate the redirect url Signed-off-by: huabing zhao <zhaohuabing@gmail.com> * remove comments Signed-off-by: huabing zhao <zhaohuabing@gmail.com> * extract method Signed-off-by: huabing zhao <zhaohuabing@gmail.com> * address comments Signed-off-by: huabing zhao <zhaohuabing@gmail.com> --------- Signed-off-by: huabing zhao <zhaohuabing@gmail.com> (cherry picked from commit ceb697f) Signed-off-by: Arko Dasgupta <arko@tetrate.io> * fix: Allow Policy to attach to multiple http listeners (#2967) * Fixing the clienttrafficpolicy validation. Signed-off-by: Lior Okman <lior.okman@sap.com> * Make SecurityPolicy validate correctly. Signed-off-by: Lior Okman <lior.okman@sap.com> * Reverted the SecurityPolicy validation - handled differently via another feature. Signed-off-by: Lior Okman <lior.okman@sap.com> * Updated the tests to reflect that this validation isn't required for SecurityPolicy Signed-off-by: Lior Okman <lior.okman@sap.com> * Added some comments to explain the validation being performed. Signed-off-by: Lior Okman <lior.okman@sap.com> * Updated the error message as requested in the review. Signed-off-by: Lior Okman <lior.okman@sap.com> --------- Signed-off-by: Lior Okman <lior.okman@sap.com> (cherry picked from commit f9409e4) Signed-off-by: Arko Dasgupta <arko@tetrate.io> * fix: set path prefix for http ext auth service (#3018) Signed-off-by: huabing zhao <zhaohuabing@gmail.com> (cherry picked from commit 2882b7c) Signed-off-by: Arko Dasgupta <arko@tetrate.io> * Change route sorting order to Exact > RegularExpression > PathPrefix (#2579) * Change route sorting order to Exact > RegularExpression > PathPrefix kubernetes-sigs/gateway-api#1770 kubernetes-sigs/gateway-api#1855 Signed-off-by: Stéphane Cottin <stephane.cottin@vixns.com> (cherry picked from commit 11f56fd) Signed-off-by: Arko Dasgupta <arko@tetrate.io> * fix: infraIR duplicate port translation for merged gateways (#3061) * fix: duplicate port translation for merged gateways Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> * refactor to map Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> * rename map Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> * add seperate testcase Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> --------- Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> (cherry picked from commit 29946b0) Signed-off-by: Arko Dasgupta <arko@tetrate.io> * translator: set SpawnUpstreamSpan to true (#3102) * translator: set SpawnUpstreamSpan to true Signed-off-by: zirain <zirain2009@gmail.com> * update Signed-off-by: zirain <zirain2009@gmail.com> --------- Signed-off-by: zirain <zirain2009@gmail.com> (cherry picked from commit 635ebfc) Signed-off-by: Arko Dasgupta <arko@tetrate.io> * fix: rate limit doesn't work with two(and more) listeners (#3085) * fix: rate limit doesn't work with two listeners Signed-off-by: huabing zhao <zhaohuabing@gmail.com> * add e2e test for rate limit on multiple listeners Signed-off-by: huabing zhao <zhaohuabing@gmail.com> * address comments Signed-off-by: huabing zhao <zhaohuabing@gmail.com> --------- Signed-off-by: huabing zhao <zhaohuabing@gmail.com> Co-authored-by: Xunzhuo <bitliu@tencent.com> (cherry picked from commit a5bedbc) Signed-off-by: Arko Dasgupta <arko@tetrate.io> * rerun make testdata Signed-off-by: Arko Dasgupta <arko@tetrate.io> --------- Signed-off-by: huabing zhao <zhaohuabing@gmail.com> Signed-off-by: Arko Dasgupta <arko@tetrate.io> Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> Signed-off-by: Jesse Haka <haka.jesse@gmail.com> Signed-off-by: lemonlinger <lemonlinger@gmail.com> Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> Signed-off-by: Lior Okman <lior.okman@sap.com> Signed-off-by: Stéphane Cottin <stephane.cottin@vixns.com> Signed-off-by: zirain <zirain2009@gmail.com> Co-authored-by: Huabing Zhao <zhaohuabing@gmail.com> Co-authored-by: Jesse Haka <haka.jesse@gmail.com> Co-authored-by: zirain <zirain2009@gmail.com> Co-authored-by: Meng <lemonlinger@gmail.com> Co-authored-by: Karol Szwaj <karol.szwaj@gmail.com> Co-authored-by: Lior Okman <lior.okman@sap.com> Co-authored-by: vixns <stephane.cottin@vixns.com> Co-authored-by: Xunzhuo <bitliu@tencent.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fix double splashes in the redirect URL
When an HTTPRoute's match is a path prefix and has a redirect filter with a replacePrefixMatch "/",
A redirect routeaction with regex_rewrite is generated to match both the prefix with and without trailing "/" to avoid double "/" in the redirect URL.
For example, given the following HTTPRoute:
The following route will be created:
See #2976 for more details.
Fix: #2976