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

Fix percent-encoding of percent sign in grpc-message header #2107

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
13 changes: 12 additions & 1 deletion tonic/src/metadata/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2500,7 +2500,7 @@ mod tests {
#[test]
fn test_to_headers_encoding() {
use crate::Status;
let special_char_message = "Beyond ascii \t\n\r🌶️💉💧🐮🍺";
let special_char_message = "Beyond 100% ascii \t\n\r🌶️💉💧🐮🍺";
let s1 = Status::unknown(special_char_message);

assert_eq!(s1.message(), special_char_message);
Expand All @@ -2509,6 +2509,17 @@ mod tests {
let s2 = Status::from_header_map(&s1_map).unwrap();

assert_eq!(s1.message(), s2.message());

assert!(
s1_map
.get("grpc-message")
.unwrap()
.to_str()
.unwrap()
.starts_with("Beyond%20100%25%20ascii"),
"Percent sign or other character isn't encoded as desired: {:?}",
s1_map.get("grpc-message")
);
}

#[test]
Expand Down
1 change: 1 addition & 0 deletions tonic/src/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const ENCODING_SET: &AsciiSet = &CONTROLS
.add(b' ')
.add(b'"')
.add(b'#')
.add(b'%')
.add(b'<')
.add(b'>')
.add(b'`')
Expand Down
Loading