diff --git a/lib/parser_block.js b/lib/parser_block.js index 23df821..ed3b7b7 100644 --- a/lib/parser_block.js +++ b/lib/parser_block.js @@ -124,7 +124,7 @@ ParserBlock.prototype.parse = function (src, md, env, outTokens) { src = src.replace(NEWLINES_RE, '\n'); // Strin NULL characters - src = src.replace(NULL_RE, ''); + src = src.replace(NULL_RE, '\uFFFD'); // Replace tabs with proper number of spaces (1..4) if (src.indexOf('\t') >= 0) { diff --git a/test/misc.js b/test/misc.js index ce9f79a..50877ac 100644 --- a/test/misc.js +++ b/test/misc.js @@ -167,7 +167,7 @@ describe('Misc', function () { it('Should strip (or replace) NULL characters', function () { var md = markdownit(); - assert.strictEqual(md.render('foo\u0000bar'), '

foobar

\n'); + assert.strictEqual(md.render('foo\u0000bar'), '

foo\uFFFDbar

\n'); }); it('Should correctly parse strings without tailing \\n', function () {