Skip to content

Commit

Permalink
ProtoJSON safely encode JSON to ASCII-8BIT (String#b) (#264)
Browse files Browse the repository at this point in the history
  • Loading branch information
stuppy authored Oct 11, 2023
1 parent d75dfee commit 0540942
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/temporal/connection/converter/payload/proto_json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def to_payload(data)
'encoding' => ENCODING,
'messageType' => data.class.descriptor.name,
},
data: data.to_json,
data: data.to_json.b,
)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@

expect(subject.from_payload(subject.to_payload(input))).to eq(input)
end

it 'encodes special characters' do
input = Temporalio::Api::Common::V1::Payload.new(
metadata: { 'it’ll work!' => 'bytebytebyte' },
)
expect(subject.from_payload(subject.to_payload(input))).to eq(input)
end
end

it 'skips if not proto message' do
Expand Down

0 comments on commit 0540942

Please sign in to comment.