Fix raw path handling in strip prefix #2382
Merged
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 fixes forwarding of URL encoded characters to the backend servers.
Given that Traefik receives a request path in the form:
/some/a%2Fb
it should forward the same path to the backend. This is the case when using e.g. the rule typePathPrefix
, but as soon as the rule type is eitherPathPrefixStrip
orPathPrefixStripRegex
the path was forwarded in the decoded form like:/some/a/b
.The reason why this solution fixes our problem is that go uses the
String()
method of theURL
object when it constructs the request. The docs state for this:For us the relevant part is with
u.EscapedPath()
and there the docs state:To understand the problem, note the sentence:
EscapedPath returns u.RawPath when it is a valid escaping of u.Path.
By stripping only the Path and not the RawPath we violated this statement and therefore the http package decided to use thePath
.