From: Feross Aboukhadijeh Date: Sun, 29 Jun 2014 15:28:35 +0000 (-0700) Subject: Add failing test for base64 newlines issue (#33) X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=209cc1bd7233157d9d7061e3f3a95a01ef820316;p=buffer.git Add failing test for base64 newlines issue (#33) --- diff --git a/test/base64-newline.js b/test/base64-newline.js new file mode 100644 index 0000000..4722aec --- /dev/null +++ b/test/base64-newline.js @@ -0,0 +1,28 @@ +var B = require('../').Buffer +var test = require('tape') + +var data = [ + '', + '' +] + +test('base64 strings with newlines / invalid charaters', function (t) { + // newline in utf8 -- should not be an issue + t.equal( + new B('LS0tCnRpdGxlOiBUaHJlZSBkYXNoZXMgbWFya3MgdGhlIHNwb3QKdGFnczoK', 'base64').toString('utf8'), + '---\ntitle: Three dashes marks the spot\ntags:\n' + ) + + // newline in base64 -- should get stripped + t.equal( + new B('LS0tCnRpdGxlOiBUaHJlZSBkYXNoZXMgbWFya3MgdGhlIHNwb3QKdGFnczoK\nICAtIHlhbWwKICAtIGZyb250LW1hdHRlcgogIC0gZGFzaGVzCmV4cGFuZWQt', 'base64').toString('utf8'), + '---\ntitle: Three dashes marks the spot\ntags:\n - yaml\n - front-matter\n - dashes\nexpaned-' + ) + + // tab characters in base64 - should get stripped + t.equal( + new B('LS0tCnRpdGxlOiBUaHJlZSBkYXNoZXMgbWFya3MgdGhlIHNwb3QKdGFnczoK\t\t\t\tICAtIHlhbWwKICAtIGZyb250LW1hdHRlcgogIC0gZGFzaGVzCmV4cGFuZWQt', 'base64').toString('utf8'), + '---\ntitle: Three dashes marks the spot\ntags:\n - yaml\n - front-matter\n - dashes\nexpaned-' + ) + t.end() +})