Skip to content

Conversation

@dazuma
Copy link
Member

@dazuma dazuma commented Jan 15, 2026

No description provided.

@dazuma dazuma force-pushed the pr/default-charset branch 2 times, most recently from 4ba2705 to acdd353 Compare January 15, 2026 02:30
@dazuma dazuma changed the title fix: Default to the utf-8 charset for non-plain-text content-types fix: Fixed default charset behavior for various non-text/plain content types Jan 15, 2026
@dazuma dazuma force-pushed the pr/default-charset branch from acdd353 to ce23938 Compare January 15, 2026 02:32
@dazuma dazuma requested a review from Copilot January 15, 2026 02:33
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request fixes the default charset behavior for various content types. Previously, us-ascii was the default charset for all content types without an explicit charset parameter. The fix introduces smarter defaults: text/plain defaults to us-ascii, text-based and JSON-based content types default to utf-8, and binary content types (like images) have no default charset.

Changes:

  • Updated ContentType class to intelligently select default charsets based on media type and subtype
  • Modified test fixtures to reflect the new behavior with proper JSON objects containing UTF-8 characters
  • Added comprehensive test coverage for the new charset defaulting logic

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
lib/cloud_events/content_type.rb Implements intelligent charset selection logic via choose_default_charset method; changes initialization to set all instance variables to nil initially and apply defaults in ensure block
test/test_content_type.rb Adds test cases for different content types and their expected charset defaults (text/plain → us-ascii, application/json → utf-8, text/html → utf-8, image/png → nil)
test/test_http_binding.rb Updates test fixtures: changes JSON test data from simple string to object with UTF-8 characters, removes charset from JSON content type string, converts all let : syntax to let(:) for consistency

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dazuma dazuma force-pushed the pr/default-charset branch from ce23938 to 4c4787b Compare January 15, 2026 05:39
@dazuma dazuma merged commit 8b70348 into cloudevents:main Jan 15, 2026
12 checks passed
@dazuma dazuma deleted the pr/default-charset branch January 15, 2026 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant