-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HtmlEncoder.Encode(ROS<char>, S<char>) returns wrong charsConsumed, charsWritten values #45994
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
Tagging subscribers to this area: @tarekgh, @krwq Issue DetailsFor an incomplete Encode it returns the wrong values and values that are larger than the input lengths Descriptionusing 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
Regression?Broken in both
|
Tagging subscribers to this area: @tarekgh Issue DetailsFor an incomplete Encode it returns the wrong values and values that are larger than the input lengths Descriptionusing 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
Regression?Broken in both
|
- Replaces unsafe code with safe code where possible - Fixes some surrogate pairs being misinterpreted - Fixes dotnet/runtime#45994 - Ref: MSRC 62749 (CVE-2021-26701)
- Replaces unsafe code with safe code where possible - Fixes some surrogate pairs being misinterpreted - Fixes dotnet/runtime#45994 - Ref: MSRC 62749 (CVE-2021-26701)
For an incomplete Encode it returns the wrong values and values that are larger than the input lengths
Description
Output
Expected Output
Configuration
netcoreapp3.1
andnet5.0
Windows 10
x64
Regression?
Broken in both
netcoreapp3.1
andnet5.0
; maybe earlier versions haven't checkedThe text was updated successfully, but these errors were encountered: