opentelemetry-go
opentelemetry-go copied to clipboard
Baggage propagation - replace invalid percent-encoded octet sequnces with replacement char
W3C baggage spec requires:
When decoding the value, percent-encoded octet sequences that do not match the UTF-8 encoding scheme MUST be replaced with the replacement code point (
U+FFFD).
This situation is currently not handled correctly - see playground for sample:
package main
import (
"fmt"
"log"
"unicode/utf8"
"go.opentelemetry.io/otel/baggage"
)
func main() {
kv := "k=aa%ffcc"
b, err := baggage.Parse(kv)
if err != nil {
log.Fatal(err)
}
val := b.Members()[0].Value()
fmt.Println(val)
fmt.Println(len(val))
fmt.Println(utf8.ValidString(val))
validStringWithReplacements := "aa�cc"
fmt.Println(len(validStringWithReplacements))
fmt.Println(utf8.ValidString(validStringWithReplacements))
}
hey @lachmatt what is the expected behavior?
that code should return 7 and true, right?
fmt.Println(len(val))
fmt.Println(utf8.ValidString(val))
that code should return 7 and true
This is correct.
From https://www.compart.com/en/unicode/U+FFFD:
UTF-8 Encoding: 0xEF 0xBF 0xBD
@pellared I could fix it, could you assign me this issue?
@pellared / @dmathieu We already merged the code to solve this issue, should we close the issue? Thanks
Fixed in https://github.com/open-telemetry/opentelemetry-go/pull/5528.