For an incomplete Encode it returns the wrong values and values that are larger than the input lengths
Description
using System;
using System.Buffers;
using System.Text.Encodings.Web;
class Program
{
static void Main()
{
const string data = "<div></div>";
char[] array = new char[16];
ReadOnlySpan<char> input = data;
Span<char> output = array;
OperationStatus status = HtmlEncoder.Default.Encode(input, output, out int charsConsumed, out int charsWritten, isFinalBlock: true);
Console.WriteLine($"status = {status}");
Console.WriteLine($"input.Length = {input.Length}");
Console.WriteLine($"output.Length = {output.Length}");
Console.WriteLine($"charsConsumed = {charsConsumed}");
Console.WriteLine($"charsWritten = {charsWritten}");
Console.WriteLine($"Data written: {output.Slice(0, charsWritten).ToString()}");
Console.WriteLine($"Data consumed: {input.Slice(0, charsConsumed).ToString()}");
}
}
Output
status = DestinationTooSmall
input.Length = 11
output.Length = 16
charsConsumed = 19
charsWritten = 19
Unhandled exception. System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Expected Output
status = DestinationTooSmall
input.Length = 11
output.Length = 16
- charsConsumed = 19
+ charsConsumed = 7
- charsWritten = 19
+ charsWritten = 16
- Unhandled exception. System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
+ Data written: <div></
+ Data consumed: <div></
Configuration
- Which version of .NET is the code running on?
netcoreapp3.1 and net5.0
- What OS and version, and what distro if applicable?
Windows 10
- What is the architecture (x64, x86, ARM, ARM64)?
x64
Regression?
Broken in both netcoreapp3.1 and net5.0; maybe earlier versions haven't checked
For an incomplete Encode it returns the wrong values and values that are larger than the input lengths
Description
Output
Expected Output
Configuration
netcoreapp3.1andnet5.0Windows 10x64Regression?
Broken in both
netcoreapp3.1andnet5.0; maybe earlier versions haven't checked