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

http: fix and generalize PercentEncoding utility. #11677

Merged
merged 1 commit into from
Jun 22, 2020

Conversation

htuch
Copy link
Member

@htuch htuch commented Jun 21, 2020

  • Fix an off-by-one bug in PercentEncoding::encode(). It doesn't appear that this utility is used
    anywhere that this would be security sensitive, but it is used for sendLocalReply() for gRPC
    messages.

  • Generalize from '%' to arbitrary visible reserved chars. RFC3986 encoding requires more
    flexibility, e.g. being able to percent encode / or #.

This change was motivated by a larger patch that provides encoding/decoding of udpa:// URIs, as part
of #11264.

Risk level: Low
Testing: Additional unit tests.

Signed-off-by: Harvey Tuch [email protected]

* Fix an off-by-one bug in PercentEncoding::encode(). It doesn't appear that this utility is used
  anywhere that this would be security sensitive, but it is used for sendLocalReply() for gRPC
  messages.

* Generalize from '%' to arbitrary visible reserved chars. RFC3986 encoding requires more
  flexibility, e.g. being able to percent encode `/` or `#`.

This change was motivated by a larger patch that provides encoding/decoding of udpa:// URIs, as part
of envoyproxy#11264.

Risk level: Low
Testing: Additional unit tests.

Signed-off-by: Harvey Tuch <[email protected]>
@dio
Copy link
Member

dio commented Jun 22, 2020

/azp run envoy-presubmit

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@dio dio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this!

@htuch htuch merged commit b2d99df into envoyproxy:master Jun 22, 2020
@htuch htuch deleted the fix-percent-encoding-2 branch June 22, 2020 15:47
@@ -158,7 +161,8 @@ class PercentEncoding {

private:
// Encodes string view to its percent encoded representation, with start index.
static std::string encode(absl::string_view value, const size_t index);
static std::string encode(absl::string_view value, const size_t index,
const absl::flat_hash_set<char>& reserved_char_set);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there tests or uses of this function? If not, we should delete it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, this helper function is used internally by encode, which does a scan first.

songhu pushed a commit to songhu/envoy that referenced this pull request Jun 25, 2020
* Fix an off-by-one bug in PercentEncoding::encode(). It doesn't appear that this utility is used
  anywhere that this would be security sensitive, but it is used for sendLocalReply() for gRPC
  messages.

* Generalize from '%' to arbitrary visible reserved chars. RFC3986 encoding requires more
  flexibility, e.g. being able to percent encode `/` or `#`.

This change was motivated by a larger patch that provides encoding/decoding of udpa:// URIs, as part
of envoyproxy#11264.

Risk level: Low
Testing: Additional unit tests.

Signed-off-by: Harvey Tuch <[email protected]>
yashwant121 pushed a commit to yashwant121/envoy that referenced this pull request Jul 24, 2020
* Fix an off-by-one bug in PercentEncoding::encode(). It doesn't appear that this utility is used
  anywhere that this would be security sensitive, but it is used for sendLocalReply() for gRPC
  messages.

* Generalize from '%' to arbitrary visible reserved chars. RFC3986 encoding requires more
  flexibility, e.g. being able to percent encode `/` or `#`.

This change was motivated by a larger patch that provides encoding/decoding of udpa:// URIs, as part
of envoyproxy#11264.

Risk level: Low
Testing: Additional unit tests.

Signed-off-by: Harvey Tuch <[email protected]>
Signed-off-by: yashwant121 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants