From: Emil Bay Date: Mon, 7 Nov 2016 07:25:57 +0000 (+1030) Subject: Fix bug with .fill bytes > 127 from other encoding X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=4e5c4526f4c29201fa833a89d8fe2bf15ebb18e5;p=buffer.git Fix bug with .fill bytes > 127 from other encoding --- diff --git a/index.js b/index.js index 7baf22a..5cbf37f 100644 --- a/index.js +++ b/index.js @@ -1544,7 +1544,7 @@ Buffer.prototype.fill = function fill (val, start, end, encoding) { } else { var bytes = Buffer.isBuffer(val) ? val - : utf8ToBytes(new Buffer(val, encoding).toString()) + : new Buffer(val, encoding) var len = bytes.length for (i = 0; i < end - start; ++i) { this[i + start] = bytes[i % len] diff --git a/test/base64.js b/test/base64.js index 9513b25..bb1bf6a 100644 --- a/test/base64.js +++ b/test/base64.js @@ -44,3 +44,12 @@ test('base64: invalid non-alphanumeric characters -- should be stripped', functi ) t.end() }) + +test('base64: high byte', function (t) { + var highByte = Buffer.from([128]) + t.deepEqual( + B.alloc(1, highByte.toString('base64'), 'base64'), + highByte + ) + t.end() +})