Skip to content

Commit

Permalink
clarify enforceUtf8 argument
Browse files Browse the repository at this point in the history
Co-authored-by: Luke Sandberg <[email protected]>
  • Loading branch information
dibenede and lukesandberg committed Jul 16, 2024
1 parent 1abea1a commit 27d4277
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions binary/decoder_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,11 +375,11 @@ describe('binaryDecoderTest', () => {

const decoder = jspb.BinaryDecoder.alloc(encoder.end());

expect(decoder.readString(ascii.length, true)).toEqual(ascii);
expect(utf8_two_bytes).toEqual(decoder.readString(2, true));
expect(decoder.readString(ascii.length, /* enforceUtf8= */ true)).toEqual(ascii);
expect(utf8_two_bytes).toEqual(decoder.readString(2, /* enforceUtf8= */ true));
expect(utf8_three_bytes)
.toEqual(decoder.readString(3, true));
expect(utf8_four_bytes).toEqual(decoder.readString(4, true));
.toEqual(decoder.readString(3, /* enforceUtf8= */ true));
expect(utf8_four_bytes).toEqual(decoder.readString(4, /* enforceUtf8= */ true));
});

/**
Expand Down
2 changes: 1 addition & 1 deletion generator/js_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,7 @@ std::string JSBinaryMethodType(const FieldDescriptor* field, bool is_writer) {
name[0] = (name[0] - 'a') + 'A';
}
if (!is_writer && field->type() == FieldDescriptor::TYPE_STRING &&
field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3) {
field->requires_utf8_validation()) {
name = name + "RequireUtf8";
}
return IsIntegralFieldWithStringJSType(field) ? (name + "String") : name;
Expand Down

0 comments on commit 27d4277

Please sign in to comment.