Skip to content

Commit 93dceea

Browse files
authored
bugfix: Handle blank media types (#1796)
* Handle blank media type better when using base64 images * Add changelog
1 parent 919c4d7 commit 93dceea

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ This document is formatted according to the principles of [Keep A CHANGELOG](htt
99
Please visit [cucumber/CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CONTRIBUTING.md) for more info on how to contribute to Cucumber.
1010

1111
## [Unreleased]
12+
### Fixed
13+
- Prevent messages (And any consuming formatters), from not handling unknown (base64), media types ([#1796](https://github.com/cucumber/cucumber-ruby/pull/1796) [luke-hill](https://github.com/luke-hill))
1214

1315
## [10.1.0] - 2025-08-20
1416
### Changed

lib/cucumber/formatter/message_builder.rb

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,16 @@ def attach(src, media_type, filename)
5353
file_name: filename
5454
}
5555

56-
if media_type.start_with?('text/')
56+
if media_type&.start_with?('text/')
5757
attachment_data[:content_encoding] = Cucumber::Messages::AttachmentContentEncoding::IDENTITY
5858
attachment_data[:body] = src
5959
else
6060
body = src.respond_to?(:read) ? src.read : src
61-
6261
attachment_data[:content_encoding] = Cucumber::Messages::AttachmentContentEncoding::BASE64
6362
attachment_data[:body] = Base64.strict_encode64(body)
6463
end
6564

66-
message = Cucumber::Messages::Envelope.new(
67-
attachment: Cucumber::Messages::Attachment.new(**attachment_data)
68-
)
69-
65+
message = Cucumber::Messages::Envelope.new(attachment: Cucumber::Messages::Attachment.new(**attachment_data))
7066
output_envelope(message)
7167
end
7268

0 commit comments

Comments
 (0)