Support full decoding of reserved expansions#45
Support full decoding of reserved expansions#45qiwzhang merged 7 commits intogrpc-ecosystem:masterfrom
Conversation
| // For multipart matches only unescape non-reserved characters. | ||
| binding.value += UrlUnescapeString(parts[i], !is_multipart); | ||
| binding.value += UrlUnescapeString( | ||
| parts[i], fully_decode_reserved_expansion || !is_multipart); |
There was a problem hiding this comment.
Hmm, we should not decode %2F even with fully_decode_reserved_expansion_
There was a problem hiding this comment.
Hm, not decoding everything beats the purpose of this change..
There was a problem hiding this comment.
Depends on how we set this flag fully_decode_reserved_expansion_? If it is from option.http, I think we should follow it.
At least its comment clearly say so.
We can add a flag in envoy grpc_transcode filter_config, as always_decode_reserved_. it may serve your purpose. I will go for it.
There was a problem hiding this comment.
Since you are here, maybe we can support both:
- one from proto file option.http, and 2) one from grpc_trancode filter_config.
since they are mutually exclusive, we can do: if 2) exists, don't use 1), otherwise check 1).
There was a problem hiding this comment.
Sounds good, let me rename the function/field with corresponding docs.
There was a problem hiding this comment.
Added support for both options, covered logic of all their combinations by tests
| return os; | ||
| } | ||
|
|
||
| } // namespace |
There was a problem hiding this comment.
Note: this is unrelated change, but it fixes pretty debug printing of Binding type in gtest (operator<< must be in the same namespace as the type it covers).
| // | ||
| // The default behavior is to not decode RFC 6570 reserved characters in multi | ||
| // segment matches. | ||
| void SetFullyDecodeReservedExpansion(bool value) { |
There was a problem hiding this comment.
-
I like the names to be more specific for readability. how about
UrlUnescapeSpec? -
These two bools are mutual exclusive, Can we combine them into one flag with an enum value?
There was a problem hiding this comment.
Thanks, updated
test/path_matcher_test.cc
Outdated
| TEST_F(PathMatcherTest, | ||
| OnlyUnreservedCharsAreUnescapedForMultiSegmentMatchAlwaysDecode) { | ||
| SetFullyDecodeReservedExpansion(true); | ||
| // All %XX are reserved characters, they should be decoded. |
There was a problem hiding this comment.
comment is wrong, slash is not be decoded
There was a problem hiding this comment.
Thanks, updated
| always_decode_); | ||
| ExtractBindingsFromPath( | ||
| method_data->variables, parts, variable_bindings, | ||
| unescape_spec_ == UrlUnescapeSpec::kAllCharacters || |
There was a problem hiding this comment.
We should not use two arguments to control one aspect. We should just one one argument. Same as UrlUnescape function.
There was a problem hiding this comment.
Passed UrlUnescapeSpec all the way through.
|
Cool, just one minor request. |
| bool unescape_reserved_chars, bool unescape_slash_char, | ||
| char* out) { | ||
| UrlUnescapeSpec unescape_spec, char* out) { | ||
| const bool unescape_slash_char = |
There was a problem hiding this comment.
the code readability is bad, you are converting an enum type into two bool, inside the loop, can we just use switch() on the spec. and handle it accordingly. the code will be much easier to read
There was a problem hiding this comment.
great point, addressed
|
@euroelessar Thanks for the PR. You need to update envoy dependent to get this change and hook it up. Thanks |
…#14009) Functionality is implemented in grpc-ecosystem/grpc-httpjson-transcoding#45, add configuration options and wire them into filter. The reasoning is provided in grpc-ecosystem/grpc-httpjson-transcoding#44. Risk Level: Low Testing: added unit test Docs Changes: added proto docs Release Notes: updated Signed-off-by: Ruslan Nigmatullin <elessar@dropbox.com>
… (#14009) Functionality is implemented in grpc-ecosystem/grpc-httpjson-transcoding#45, add configuration options and wire them into filter. The reasoning is provided in grpc-ecosystem/grpc-httpjson-transcoding#44. Risk Level: Low Testing: added unit test Docs Changes: added proto docs Release Notes: updated Signed-off-by: Ruslan Nigmatullin <elessar@dropbox.com> Mirrored from https://github.com/envoyproxy/envoy @ 39e43e1abb45c96993f2df3323df12bc94937910
…envoyproxy#14009) Functionality is implemented in grpc-ecosystem/grpc-httpjson-transcoding#45, add configuration options and wire them into filter. The reasoning is provided in grpc-ecosystem/grpc-httpjson-transcoding#44. Risk Level: Low Testing: added unit test Docs Changes: added proto docs Release Notes: updated Signed-off-by: Ruslan Nigmatullin <elessar@dropbox.com>
…envoyproxy#14009) Functionality is implemented in grpc-ecosystem/grpc-httpjson-transcoding#45, add configuration options and wire them into filter. The reasoning is provided in grpc-ecosystem/grpc-httpjson-transcoding#44. Risk Level: Low Testing: added unit test Docs Changes: added proto docs Release Notes: updated Signed-off-by: Ruslan Nigmatullin <elessar@dropbox.com> Signed-off-by: Qin Qin <qqin@google.com>
… (#14009) Functionality is implemented in grpc-ecosystem/grpc-httpjson-transcoding#45, add configuration options and wire them into filter. The reasoning is provided in grpc-ecosystem/grpc-httpjson-transcoding#44. Risk Level: Low Testing: added unit test Docs Changes: added proto docs Release Notes: updated Signed-off-by: Ruslan Nigmatullin <elessar@dropbox.com>
Implement underlying logic for
google.api.Http.fully_decode_reserved_expansion.Add a configurable option to always decode all path and query bindings.
Fixes #44