\r only in token scanner

An edge case was lost with this commit 31ca3640d2

when scanner is only followed by \r (without \n)
This commit is contained in:
romain v
2021-08-17 16:14:59 +02:00
parent 3f1035cd6d
commit 47a0a62eee

View File

@@ -262,6 +262,7 @@
}
// From the specification: The stream operator should be followed by \r\n or \n, not just \r.
// While the specification demands a \n we have seen files with \r only in the wild.
// While the specification demands a \n we have seen files with `garbage` before the actual data
do
{
@@ -269,6 +270,21 @@
{
return false;
}
if ((char)inputBytes.CurrentByte == '\r')
{
if (!inputBytes.MoveNext())
{
return false;
}
if ((char)inputBytes.CurrentByte != '\n')
{
inputBytes.Seek(inputBytes.CurrentOffset - 1);
}
break;
}
} while ((char)inputBytes.CurrentByte != '\n');
// Store where we started reading the first byte of data.