Skip to content

Commit a76bb59

Browse files
author
Martii
committed
Correctly use Buffer length instead of String length for "Chunking"
* Thanks to *node* maintainer for the clarification at nodejs/node#3219 of Buffer length versus character length * Retested on a User Script that contained a lot of Unicode characters in a comment at the beginning then the metadata blocks at the EOF... String.length fails to upload... Buffer length passes on upload with two "chunks" Applies to OpenUserJS#678
1 parent 1cf54b5 commit a76bb59

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

controllers/scriptStorage.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,10 @@ exports.getMeta = function (aBufs, aCallback) {
342342
var blocks = {};
343343

344344
for (; i < aBufs.length; ++i) {
345-
// Convert the current Buffer to a `String` and accumulate it's `String` totalLength
346-
len += aBufs[i].toString('utf8').length; // NOTE: Watchpoint
345+
// Accumulate the indexed Buffer length to use with `totalLength` parameter
346+
len += aBufs[i].length;
347347

348-
// Read from the start of the Buffers to the `String` length end-point
348+
// Read from the start of the Buffers to the Buffers length end-point
349349
// See also #678
350350
str = Buffer.concat(aBufs, len).toString('utf8');
351351

0 commit comments

Comments
 (0)