Ben Noordhuis
f101f7c9ba
buffers: honor length argument in base64 decoder
Honor the length argument in `buf.write(s, 0, buf.length, 'base64')`. Before
this commit, the length argument was ignored. The decoder would keep writing
until it hit the end of the buffer. Since most buffers in Node are slices of
a parent buffer (the slab), this bug would overwrite the content of adjacent
buffers.
The bug is trivially demonstrated with the following test case:
var assert = require('assert');
var a = Buffer(3);
var b = Buffer('xxx');
a.write('aaaaaaaa', 'base64');
assert.equal(b.toString(), 'xxx');
This commit coincidentally also fixes a bug where Buffer._charsWritten was not
updated for zero length buffers.
13 years ago
Ryan Dahl
d77ce4b998
Fixes #1860 . Remove process.writeError
Breaks a few tests in "make test-message"
13 years ago
Colton Baker
87286cc737
Fixed a lot of jslint errors.
Fixes #1831
13 years ago
Ben Noordhuis
f6bce20e5e
buffers: handle bad length argument in constructor
Coerce fractional, negative and non-numeric length arguments to numbers.
Fractional numbers are rounded up, negative numbers and non-numeric values
are set to zero.
13 years ago
Ben Noordhuis
d157131439
buffers: handle bad length argument in constructor
Coerce fractional, negative and non-numeric length arguments to numbers.
Fractional numbers are rounded up, negative numbers and non-numeric values
are set to zero.
13 years ago
koichik
3e853e627e
buffer: write() should always set _charsWritten.
Refs #1633 .
13 years ago
koichik
96ede8cc9b
buffer: Avoid overrun with 'binary' encoding.
Fixes #1624 .
13 years ago
koichik
526c54c979
buffer: write() should always set _charsWritten.
Fixes #1633 .
13 years ago
koichik
50e147bd03
Add an optional length argument to Buffer.write()
Fixes #243 .
Fixes #1361 .
13 years ago
koichik
5208abe723
Fix Buffer drops last null character in UTF-8
Reproduce:
$ node
> buf = new Buffer('\0')
<Buffer >
> buf.length
0
> buf = new Buffer(1)
<Buffer 28>
> buf.write('\0')
0
Fixes #394 .
Fixes #1210 .
14 years ago
Ben Noordhuis
8e0d788842
Test for #402 : writing base64 at position > 0 should not mangle the result.
This is a regression test, the bug itself was fixed in v0.3.x.
14 years ago
Ryan Dahl
6461af1baa
Fix buffer test
14 years ago
Ryan Dahl
5e409c2f1a
makeFastBuffer should not segfault but rather throw on non-buffer
14 years ago
Ryan Dahl
103a450d3a
Remove 'binary' encoding assert - add tests
Don't write large characters to buffers with binary encoding. You will be
silently injured.
14 years ago
Konstantin Käfer
5e1b7cadb4
Add Buffer::fill method to do memset
Fixes #477 .
14 years ago
koichik
fcc04e67c8
Fix SlowBuffer.write() with 'ucs2' throws ReferenceError.
14 years ago
koichik
9533e879f0
Fix Buffer.write() with UCS-2 should not be write partial char
closes #916 .
14 years ago
Ryan Dahl
038306a6c3
Closes GH-843. Fix SlowBuffer.prototype.slice
14 years ago
isaacs
3c9fb3ec1a
Fix invalid end handling for SlowBuffer#hexSlice
14 years ago
Ryan Dahl
55048cdf79
Update copyright headers
14 years ago
isaacs
0aa1a8a005
Closes GH-695 Add 'hex' encoding to Buffer
14 years ago
Ryan Dahl
0474ce6790
Revert "buffer.toString() shouldn't include null values"
This reverts commit 909a5b39d2
.
Will fix inside V8's String::New instead.
14 years ago
Ryan Dahl
909a5b39d2
buffer.toString() shouldn't include null values
14 years ago
isaacs
2e6a263e29
Closes GH-609 Support array-ish args to Buffer ctor
Any array-ish thing (whether a Buffer, an Array, or just an object with
a numeric "length") is interpreted as a list of bytes.
14 years ago
Konstantin Käfer
9e101f2b01
UCS-2 support
Closes GH-644.
14 years ago
Tom Hughes
0d58353d66
Don't access buffer data before initializing it.
Prevents valgrind from complaining and still tests that buffer data is
treated as unsigned.
14 years ago
Oleg Efimov
0665f0271e
GJSLint all simple tests exclude http-*, url, path
14 years ago
Ryan Dahl
fbdff52b44
Fix global leaks in test-buffer.js
14 years ago
Ryan Dahl
4f32a59307
Fix buffer.slice(0, 0)
14 years ago
Jorge Chamorro Bieling
c735b4663a
unbase64 skips over *any* illegal chars
14 years ago
Ryan Dahl
cf1db4f304
base64 decode should handle whitespace
14 years ago
Ryan Dahl
776754c33f
Remove process._byteLength
14 years ago
Ryan Dahl
77fc61d539
Default value for second arg of Buffer#slice
14 years ago
Ryan Dahl
efc723787a
Fix big string bug
14 years ago
Ryan Dahl
3e9f636b64
Improve long buffer test
14 years ago
Ryan Dahl
8078ed1f86
Expose fast-buffer bug in tests
14 years ago
Ryan Dahl
7b772f3f68
More fast buffer work
14 years ago
Ryan Dahl
d5bdda74c1
fast buffer bounds checking in copy()
14 years ago
Ryan Dahl
f86ad1693f
Safe Constructor: Buffer
14 years ago
Herbert Vojčík
cf2b206a8e
More changes to tests so they really work under context module loader.
Plus, getting rid of test/common.js defining things in global.
14 years ago
Ryan Dahl
7db5c8a10d
Fix toString('base64') bug
Thanks to Stepan Stolyarov for the test case.
14 years ago
Ben Noordhuis
f72ac17c89
Buffer: graciously handle padding in base64-encoded input.
14 years ago
Ryan Dahl
f291fbc8a7
Fix ending \0 in base64 decoding
14 years ago
Ben Noordhuis
95638c9b0d
Buffer: adjust buffer size so the base64-decoded input fits snugly.
Stops Valgrind from complaining about uninitialized memory access.
14 years ago
Dmitry Baranovskiy
8ab3c3e7c3
Added ability to pass offset to buffer write and toString methods as a string, i.e. '2' and encoding as anything
14 years ago
Ryan Dahl
2c1ca4078d
Implement buffer.write for base64
There might be an off-by-one on the returned value.
14 years ago
Ryan Dahl
528015e0d8
Implement buffer.toString('base64')
14 years ago
Peter Griess
56f200af5d
Fix Buffer.toString() on 0-length slices.
- Buffer.toString('ascii', 0, 0) incorrectly returns the entire contents
of the buffer. Fix this.
- Provide similar behavior to Buffer.write() and Buffer.copy() when
dealing with 0-length in valid and invalid byte ranges.
14 years ago
Ryan Dahl
9fd5e3c89c
Update tests to work with module contexts
15 years ago
Peter Griess
e7c4f8cdaa
Buffer.copy() should liberally allow empty copies.
15 years ago