зеркало из https://github.com/stride3d/SharpYaml.git
Fix lost characters when emitting folded scalars with carriage returns.
This commit is contained in:
Родитель
9a6d64ec45
Коммит
7d1dea8a23
|
@ -1131,10 +1131,10 @@ namespace YamlDotNet.Core
|
|||
{
|
||||
if (!previous_break && !leadingSpaces && character == '\n')
|
||||
{
|
||||
do
|
||||
while ((i + 1) < value.Length && IsBreak(value[i + 1]))
|
||||
{
|
||||
++i;
|
||||
} while (i < value.Length && IsBreak(value[i]));
|
||||
};
|
||||
|
||||
if (i >= value.Length || value[i] != ' ')
|
||||
{
|
||||
|
|
|
@ -19,11 +19,12 @@
|
|||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Xunit;
|
||||
using YamlDotNet.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Xunit;
|
||||
using Xunit.Extensions;
|
||||
using YamlDotNet.Core;
|
||||
using YamlDotNet.Core.Events;
|
||||
|
||||
namespace YamlDotNet.UnitTests
|
||||
|
@ -169,6 +170,28 @@ namespace YamlDotNet.UnitTests
|
|||
public void EmitExample14()
|
||||
{
|
||||
ParseAndEmit("test14.yaml");
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("LF hello\nworld")]
|
||||
[InlineData("CRLF hello\r\nworld")]
|
||||
public void FoldedStyleDoesNotLooseCharacters(string text)
|
||||
{
|
||||
var buffer = new StringWriter();
|
||||
var emitter = new Emitter(buffer);
|
||||
emitter.Emit(new StreamStart());
|
||||
emitter.Emit(new DocumentStart(null, null, true));
|
||||
emitter.Emit(new SequenceStart(null, null, false, SequenceStyle.Block));
|
||||
|
||||
emitter.Emit(new Scalar(null, null, text, ScalarStyle.Folded, true, false));
|
||||
|
||||
emitter.Emit(new SequenceEnd());
|
||||
emitter.Emit(new DocumentEnd(true));
|
||||
emitter.Emit(new StreamEnd());
|
||||
|
||||
var yaml = buffer.ToString();
|
||||
Console.WriteLine(yaml);
|
||||
Assert.True(yaml.Contains("world"));
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче