Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 1dfe78c

Browse files
committed
Remove UTF8 BOM when deserializing as well
1 parent 4b3540d commit 1dfe78c

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/ServiceStack.Text/DefaultMemory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ private static object Deserialize(MemoryStream ms, bool fromPool, Type type,
494494
try
495495
{
496496
var charsWritten = Encoding.UTF8.GetChars(bytes, 0, (int) ms.Length, utf8, 0);
497-
var ret = deserializer(type, new ReadOnlySpan<char>(utf8, 0, charsWritten));
497+
var ret = deserializer(type, new ReadOnlySpan<char>(utf8, 0, charsWritten).WithoutBom());
498498
return ret;
499499
}
500500
finally

src/ServiceStack.Text/NetCoreMemory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public override async Task<object> DeserializeAsync(Stream stream, Type type, De
141141

142142
private static object Deserialize(MemoryStream memoryStream, bool fromPool, Type type, DeserializeStringSpanDelegate deserializer)
143143
{
144-
var bytes = memoryStream.GetBufferAsSpan();
144+
var bytes = memoryStream.GetBufferAsSpan().WithoutBom();
145145
var chars = CharPool.GetBuffer(Encoding.UTF8.GetCharCount(bytes));
146146
try
147147
{

0 commit comments

Comments
 (0)