Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build errors from utf8 enforcement changes #218

Merged
merged 1 commit into from
Jul 16, 2024
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
17 changes: 2 additions & 15 deletions binary/decoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ jspb.BinaryDecoder.prototype.readSplitFixed64 = function(convert) {
*/
jspb.BinaryDecoder.prototype.checkCursor = function () {
if (this.cursor_ > this.end_) {
asserts.fail('Read past the end ' + this.cursor_ + ' > ' + this.end_);
jspb.asserts.fail('Read past the end ' + this.cursor_ + ' > ' + this.end_);
}
}

Expand Down Expand Up @@ -902,23 +902,10 @@ jspb.BinaryDecoder.prototype.readString = function (length, requireUtf8) {
this.cursor_ += length;
this.checkCursor();
const result =
jspb.binary.utf8.decodeUtf8(jspb.asserts.assert(this.bytes_), cursor, length, requireUtf8);
jspb.binary.utf8.decodeUtf8(jspb.asserts.assert(this.bytes_), cursor, length, requireUtf8);
return result;
};


/**
* Reads and parses a UTF-8 encoded unicode string (with length prefix) from
* the stream.
* @return {string} The decoded string.
* @export
*/
jspb.BinaryDecoder.prototype.readStringWithLength = function() {
var length = this.readUnsignedVarint32();
return this.readString(length);
};


/**
* Reads a block of raw bytes from the binary stream.
*
Expand Down
3 changes: 1 addition & 2 deletions binary/utf8.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ let textEncoderInstance;
jspb.binary.utf8.textEncoderEncode = function (
/** string */ s, /** boolean */ rejectUnpairedSurrogates) {
if (rejectUnpairedSurrogates) {
checkWellFormed(s);
jspb.binary.utf8.checkWellFormed(s);
}

if (!textEncoderInstance) {
Expand Down Expand Up @@ -423,4 +423,3 @@ jspb.binary.utf8.encodeUtf8 = function (
jspb.binary.utf8.textEncoderEncode(string, rejectUnpairedSurrogates) :
jspb.binary.utf8.polyfillEncode(string, rejectUnpairedSurrogates);
}