-
Notifications
You must be signed in to change notification settings - Fork 233
Description
Context
I am working with a service that consumes CloudEvents produced by another service using the CloudEvents .NET SDK.
The issue arises with the data_base64
field in the messages produced by the second service. Specifically, this field contains the character sequence \u002B
, which represents the +
character. According to the specification RFC4648, the backslash character (\
) is not permitted, leading to potential parsing errors.
Upon encountering this issue, I reported it to the CloudEvents C# SDK repository. In response, John Skeet clarified that the use of \u002B
to represent the +
character is a valid encoding method within JSON, and the +
itself is indeed a valid character according to RFC4648.
This suggests that the handling or decoding of such sequences needs to be managed correctly by the consuming application or library.
Steps to reproduce
// simplified event based on jskeet input
jsonData := `{
"specversion": "1.0",
"id": "00716a6e-6063-43d3-8717-66888f060055",
"source": "urn:aws-global:7777",
"type": "updated.v1",
"datacontenttype": "application/octet-stream",
"data_base64": "\\u002B\\u002B\\u002B\\u002B"
}`
var eventWithBase64Data cloudevents.Event
if err := json.Unmarshal([]byte(jsonData), &eventWithBase64Data); err != nil {
slog.Error("Failed to unmarshal cloudevent JSON", err)
}
/// output:
/// ERROR Failed to unmarshal cloudevent JSON !BADKEY="illegal base64 data at input byte 0"