Skip to content

Improper charset handling in CloudEvents::HttpBinding#decode_event #109

Description

@codener

CloudEvents::HttpBinding#decode_event instantiates a CloudEvents::ContentType instance, which default to a charset of us-ascii. Next, it enforces that default charset onto the input string. Unfortunately, there seems to be no way to set the charset explicitly.

This lets the JSON parser crash when the input string contains non-ASCII characters (e.g. a German ä) in json versions 2.8 and above (2.18 checked). json 2.7 is less strict on encoding and does not crash.

Please check and confirm this issue. I'll be happy to prepare a PR.

Activity

  1. self-assigned this
    on Jan 13, 2026
  2. dazuma commented on Jan 13, 2026

    @dazuma
    Member

    Thanks for the report. I'm looking into this now.

  3. dazuma commented on Jan 15, 2026

    @dazuma
    Member

    You're correct, the CloudEvents::ContentType class incorrectly defaults to us-ascii for all content types, even though some types, like JSON, expect utf-8. It looks like us-ascii is still an appropriate default for text/plain, especially in the case where the content type is not specified, but most text-based content types, including JSON, probably expect utf-8, so I'm adjusting the logic accordingly: #111

  4. codener commented on Jan 15, 2026

    @codener
    Author

    Awesome! Thanks for the quick reaction.

  5. dazuma commented on Jan 15, 2026

    @dazuma
    Member

    cloud_events 0.8.3 released with the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions