Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/rb/ext/binary_protocol_accelerated.c
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ VALUE rb_thrift_binary_proto_read_message_begin(VALUE self) {
rb_exc_raise(get_protocol_exception(INT2FIX(PROTOERR_BAD_VERSION), rb_str_new2("No version identifier, old protocol client?")));
}
CHECK_STRING_SIZE(self, version);
name = READ(self, version);
name = convert_to_string(READ(self, version));
type = read_byte_direct(self);
seqid = rb_thrift_binary_proto_read_i32(self);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/rb/lib/thrift/protocol/binary_protocol.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def read_message_begin
raise ProtocolException.new(ProtocolException::BAD_VERSION, "No version identifier, old protocol client?")
end
check_string_size(version)
name = trans.read_all(version)
name = Bytes.convert_to_string(trans.read_all(version))
type = read_byte
seqid = read_i32
[name, type, seqid]
Expand Down
13 changes: 13 additions & 0 deletions lib/rb/spec/binary_protocol_spec_shared.rb
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,19 @@
expect(@trans.read(@trans.available)).to eq("\200\001\000\001\000\000\000\vtestMessage\000\000\000\021")
end

it "should read a UTF-8 message name with and without a version" do
name = "h\u00E9llo".encode("UTF-8")
utf8_bytes = [0x68, 0xC3, 0xA9, 0x6C, 0x6C, 0x6F].pack("C*")
{
true => [protocol_class.const_get(:VERSION_1) | Thrift::MessageTypes::CALL, 6].pack("NN") + utf8_bytes + [17].pack("N"),
false => [6].pack("N") + utf8_bytes + [Thrift::MessageTypes::CALL, 17].pack("cN"),
}.each do |versioned, bytes|
@trans.write(bytes)
actual_name, type, seqid = protocol_class.new(@trans, false, false).read_message_begin
expect([versioned, actual_name, actual_name.encoding, type, seqid]).to eq([versioned, name, Encoding::UTF_8, Thrift::MessageTypes::CALL, 17])
end
end

# message footer is a noop

it "should read a field header" do
Expand Down
Loading