From f6f89554c9245716115fc7b87c32ae628f7fe0f4 Mon Sep 17 00:00:00 2001 From: richardhopton Date: Mon, 19 Mar 2018 09:09:57 -0700 Subject: [PATCH] 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. --- .../BufferedReadStream.cs | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/Microsoft.AspNetCore.WebUtilities/BufferedReadStream.cs b/src/Microsoft.AspNetCore.WebUtilities/BufferedReadStream.cs index a6c4106d80..b72920df4d 100644 --- a/src/Microsoft.AspNetCore.WebUtilities/BufferedReadStream.cs +++ b/src/Microsoft.AspNetCore.WebUtilities/BufferedReadStream.cs @@ -327,21 +327,12 @@ namespace Microsoft.AspNetCore.WebUtilities builder.WriteByte(b); _bufferOffset++; _bufferCount--; - if (b == CR) + if (b == LF && foundCR) { - foundCR = true; - } - else if (b == LF) - { - if (foundCR) - { - foundCRLF = true; - } - else - { - foundCR = false; - } + foundCRLF = true; + return; } + foundCR = b == CR; } private string DecodeLine(MemoryStream builder, bool foundCRLF)