Fix toString('base64') bug
Thanks to Stepan Stolyarov for the test case.
This commit is contained in:
Родитель
24c6d26cca
Коммит
7db5c8a10d
|
@ -327,7 +327,7 @@ Handle<Value> Buffer::Base64Slice(const Arguments &args) {
|
|||
int out_len = (n + 2 - ((n + 2) % 3)) / 3 * 4;
|
||||
char *out = new char[out_len];
|
||||
|
||||
char bitbuf[3];
|
||||
uint8_t bitbuf[3];
|
||||
int i = start; // data() index
|
||||
int j = 0; // out index
|
||||
char c;
|
||||
|
|
|
@ -306,3 +306,11 @@ assert.equal(new Buffer('72INjkR5fchcxk9+VgdGPFJDxUBFR5/rMFsghgxADiw', 'base64
|
|||
assert.equal(new Buffer('w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg==', 'base64').length, 31);
|
||||
assert.equal(new Buffer('w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg=', 'base64').length, 31);
|
||||
assert.equal(new Buffer('w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg', 'base64').length, 31);
|
||||
|
||||
// This string encodes single '.' character in UTF-16
|
||||
dot = new Buffer('//4uAA==', 'base64');
|
||||
assert.equal(dot[0], 0xff);
|
||||
assert.equal(dot[1], 0xfe);
|
||||
assert.equal(dot[2], 0x2e);
|
||||
assert.equal(dot[3], 0x00);
|
||||
assert.equal(dot.toString('base64'), '//4uAA==');
|
||||
|
|
Загрузка…
Ссылка в новой задаче