Fix trimming line if CR not directly before LF (#1006)

If the line contains a CR in any location than directly before the LF it would detect a valid line and then trim 2 characters from the end of the line, losing a "real" character.
This commit is contained in:
richardhopton 2018-03-19 09:09:57 -07:00 committed by Chris Ross
parent f3ac1fac0c
commit f6f89554c9
1 changed files with 4 additions and 13 deletions

View File

@ -327,21 +327,12 @@ namespace Microsoft.AspNetCore.WebUtilities
builder.WriteByte(b); builder.WriteByte(b);
_bufferOffset++; _bufferOffset++;
_bufferCount--; _bufferCount--;
if (b == CR) if (b == LF && foundCR)
{ {
foundCR = true; foundCRLF = true;
} return;
else if (b == LF)
{
if (foundCR)
{
foundCRLF = true;
}
else
{
foundCR = false;
}
} }
foundCR = b == CR;
} }
private string DecodeLine(MemoryStream builder, bool foundCRLF) private string DecodeLine(MemoryStream builder, bool foundCRLF)