,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1
,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40
,41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1
+ ,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
+ ,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
+ ,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
+ ,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
+ ,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
+ ,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
+ ,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
+ ,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
};
-#define unbase64(x) unbase64_table[(int)(x)]
+#define unbase64(x) unbase64_table[(uint8_t)(x)]
Handle<Value> Buffer::Base64Slice(const Arguments &args) {
assert.equal(quote.length, b.length);
assert.equal(quote, b.toString('ascii', 0, quote.length));
+// check that the base64 decoder ignores illegal chars
+var expectedIllegal = expected.slice(0, 60) + " \x80" +
+ expected.slice(60, 120) + " \xff" +
+ expected.slice(120, 180) + " \x00" +
+ expected.slice(180, 240) + " \x98" +
+ expected.slice(240, 300) + "\x03" +
+ expected.slice(300, 360)
+b = new Buffer(expectedIllegal, 'base64');
+assert.equal(quote.length, b.length);
+assert.equal(quote, b.toString('ascii', 0, quote.length));
+
assert.equal(new Buffer('', 'base64').toString(), '');
assert.equal(new Buffer('K', 'base64').toString(), '');