Skip to content

Commit

Permalink
Fix build errors from utf8 enforcement changes
Browse files Browse the repository at this point in the history
This change fixes some minor build issues from not using fully
specified function names. There was also a missing parameter issue for
BinaryDecoder.readStringWithLength's invocation of readString, but the
former appears to be dead code so just removed it.
  • Loading branch information
dibenede committed Jul 16, 2024
1 parent 27d4277 commit 16cb293
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
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);
}

0 comments on commit 16cb293

Please sign in to comment.