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

baggage: Accept non-ASCII keys #5132

Merged
merged 35 commits into from
Aug 15, 2024
Merged
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
c81a51e
Allow UTF-8 string in baggage key
XSAM Mar 30, 2024
bc9c5b8
Merge remote-tracking branch 'upstream/main' into utf8-baggage
XSAM Apr 2, 2024
dc96def
Update CHANGELOG
XSAM Apr 2, 2024
7d9d476
Merge branch 'main' into utf8-baggage
hanyuancheung Apr 5, 2024
6501fba
Merge branch 'main' into utf8-baggage
hanyuancheung Apr 5, 2024
a037804
Merge remote-tracking branch 'upstream/main' into utf8-baggage
XSAM Apr 20, 2024
9434b2f
Allow UTF-8 in property key
XSAM Apr 20, 2024
171b0db
Fix tests
XSAM Apr 21, 2024
ce67af3
Allow UTF-8 in key to be parsed
XSAM Apr 21, 2024
e864429
Add more tests to cover 100% of lines
XSAM Apr 21, 2024
097d8a2
Update CHANGELOG
XSAM Apr 21, 2024
d716cec
Add more tests
XSAM Apr 21, 2024
c4497c1
Merge remote-tracking branch 'upstream/main' into utf8-baggage
XSAM Jun 19, 2024
a07ffb4
Allow empty string as baggage value
XSAM Jun 19, 2024
6d50ce2
Merge remote-tracking branch 'upstream/main' into utf8-baggage
XSAM Jul 3, 2024
6c289d9
Keep the behavior of W3C baggage propagator
XSAM Jul 3, 2024
6c01460
Revert the behavior of Parse to only parse W3C Baggage
XSAM Jul 3, 2024
1a88be7
Update CHANGELOG
XSAM Jul 3, 2024
7c344d6
Merge branch 'main' into utf8-baggage
XSAM Jul 16, 2024
6eed4e0
Update comments
XSAM Jul 17, 2024
ef3973e
Revert the behavior of NewMember
XSAM Jul 21, 2024
99fcf53
Revert the behavior of NewKeyValueProperty
XSAM Jul 21, 2024
8d69418
Update CHANGELOG
XSAM Jul 21, 2024
5200935
Merge remote-tracking branch 'upstream/main' into utf8-baggage
XSAM Jul 21, 2024
9a85415
Update comments
XSAM Jul 21, 2024
a544f84
Remove the key escaping in `String` method of `Member`
XSAM Jul 24, 2024
e8e07f3
Update baggage/baggage.go
pellared Jul 24, 2024
1010792
Merge branch 'main' into utf8-baggage
pellared Jul 24, 2024
4289316
Merge branch 'main' into utf8-baggage
XSAM Jul 27, 2024
66d8cd1
Add more comments
XSAM Aug 1, 2024
3060759
Merge branch 'main' into utf8-baggage
XSAM Aug 1, 2024
78c6cd7
Merge branch 'main' into utf8-baggage
XSAM Aug 2, 2024
59b314f
Merge branch 'main' into utf8-baggage
XSAM Aug 5, 2024
09371b8
Merge branch 'main' into utf8-baggage
XSAM Aug 8, 2024
9559edd
Merge branch 'main' into utf8-baggage
XSAM Aug 15, 2024
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
14 changes: 14 additions & 0 deletions baggage/baggage.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ type Property struct {
//
// The passed key must be valid, non-empty UTF-8 string.
// If key is invalid, an error will be returned.
// However, the specific Propagators that are used to transmit baggage entries across
// component boundaries may impose their own restrictions on Property key.
// For example, the W3C Baggage specification restricts the Property keys to strings that
// satisfy the token definition from RFC7230, Section 3.2.6.
// For maximum compatibility, alpha-numeric value are strongly recommended to be used as Property key.
func NewKeyProperty(key string) (Property, error) {
if !validateBaggageName(key) {
return newInvalidProperty(), fmt.Errorf("%w: %q", errInvalidKey, key)
Expand Down Expand Up @@ -155,6 +160,9 @@ func (p Property) Value() (string, bool) {

// String encodes Property into a header string compliant with the W3C Baggage
// specification.
// It would return empty string if the key is invalid with the W3C Baggage
// specification. This could happen for a UTF-8 key, as it may contain
// invalid characters.
pellared marked this conversation as resolved.
Show resolved Hide resolved
func (p Property) String() string {
// W3C Baggage specification does not allow percent-encoded keys.
if !validateKey(p.key) {
Expand Down Expand Up @@ -397,6 +405,9 @@ func (m Member) Properties() []Property { return m.properties.Copy() }

// String encodes Member into a header string compliant with the W3C Baggage
// specification.
// It would return empty string if the key is invalid with the W3C Baggage
// specification. This could happen for a UTF-8 key, as it may contain
// invalid characters.
pellared marked this conversation as resolved.
Show resolved Hide resolved
func (m Member) String() string {
// W3C Baggage specification does not allow percent-encoded keys.
if !validateKey(m.key) {
Expand Down Expand Up @@ -596,6 +607,9 @@ func (b Baggage) Len() int {

// String encodes Baggage into a header string compliant with the W3C Baggage
// specification.
// It would ignore members where the member key is invalid with the W3C Baggage
// specification. This could happen for a UTF-8 key, as it may contain
// invalid characters.
pellared marked this conversation as resolved.
Show resolved Hide resolved
func (b Baggage) String() string {
members := make([]string, 0, len(b.list))
for k, v := range b.list {
Expand Down