From 9bcb148d1e58092413d4e05f0d5a2f60fe6c3c3f Mon Sep 17 00:00:00 2001 From: Knagis Date: Thu, 25 Jun 2015 22:34:54 +0300 Subject: [PATCH] \u0000 characters are no longer removed, instead they are replaced with \uFFFD. --- CommonMark.Tests/GeneralTests.cs | 2 +- CommonMark.Tests/SourcePositionTests.cs | 2 +- CommonMark/Parser/TabTextReader.cs | 12 +----------- 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/CommonMark.Tests/GeneralTests.cs b/CommonMark.Tests/GeneralTests.cs index 4cdcd77..f441cc1 100644 --- a/CommonMark.Tests/GeneralTests.cs +++ b/CommonMark.Tests/GeneralTests.cs @@ -17,7 +17,7 @@ public class GeneralTests [TestCategory("Security")] public void TestZeroCharRemoval() { - Helpers.ExecuteTest("\u0000*foo*\0", "

foo

"); + Helpers.ExecuteTest("\u0000*foo*\0", "

\uFFFDfoo\uFFFD

"); } [TestMethod] diff --git a/CommonMark.Tests/SourcePositionTests.cs b/CommonMark.Tests/SourcePositionTests.cs index 1c02e5f..c386400 100644 --- a/CommonMark.Tests/SourcePositionTests.cs +++ b/CommonMark.Tests/SourcePositionTests.cs @@ -165,7 +165,7 @@ public void SourcePositionComplex() { "**foo**", "foo", - "bar", + "\0bar", "*quoting **is nice***", "**is nice**", "`right`", diff --git a/CommonMark/Parser/TabTextReader.cs b/CommonMark/Parser/TabTextReader.cs index 705a8d6..80523df 100644 --- a/CommonMark/Parser/TabTextReader.cs +++ b/CommonMark/Parser/TabTextReader.cs @@ -80,17 +80,7 @@ public void ReadLine(LineInfo line) } else if (c == '\0') { - if (!useBuilder) - { - useBuilder = true; - this._builder.Length = 0; - } - - if (line.IsTrackingPositions) - line.AddOffset(this._previousBufferLength + num + tabIncreaseCount, 1); - - this._builder.Append(this._buffer, this._bufferPosition, num - this._bufferPosition); - this._bufferPosition = num + 1; + this._buffer[num] = '\uFFFD'; } num++;