Browse Source

Replace null characters with 0xFFFD instead of strip

pull/25/head
Vitaly Puzrin 10 years ago
parent
commit
b2a212ffc3
  1. 2
      lib/parser_block.js
  2. 2
      test/misc.js

2
lib/parser_block.js

@ -124,7 +124,7 @@ ParserBlock.prototype.parse = function (src, md, env, outTokens) {
src = src.replace(NEWLINES_RE, '\n'); src = src.replace(NEWLINES_RE, '\n');
// Strin NULL characters // Strin NULL characters
src = src.replace(NULL_RE, ''); src = src.replace(NULL_RE, '\uFFFD');
// Replace tabs with proper number of spaces (1..4) // Replace tabs with proper number of spaces (1..4)
if (src.indexOf('\t') >= 0) { if (src.indexOf('\t') >= 0) {

2
test/misc.js

@ -167,7 +167,7 @@ describe('Misc', function () {
it('Should strip (or replace) NULL characters', function () { it('Should strip (or replace) NULL characters', function () {
var md = markdownit(); var md = markdownit();
assert.strictEqual(md.render('foo\u0000bar'), '<p>foobar</p>\n'); assert.strictEqual(md.render('foo\u0000bar'), '<p>foo\uFFFDbar</p>\n');
}); });
it('Should correctly parse strings without tailing \\n', function () { it('Should correctly parse strings without tailing \\n', function () {

Loading…
Cancel
Save