mirror of
https://github.com/UglyToad/PdfPig.git
synced 2026-03-10 00:23:29 +08:00
Tolerate any white-space bytes after the stream operator.
This commit is contained in:
@@ -256,35 +256,20 @@
|
|||||||
|
|
||||||
// Verify again that we start with "stream"
|
// Verify again that we start with "stream"
|
||||||
var hasStartStreamToken = ReadStreamTokenStart(inputBytes, startStreamTokenOffset);
|
var hasStartStreamToken = ReadStreamTokenStart(inputBytes, startStreamTokenOffset);
|
||||||
|
|
||||||
if (!hasStartStreamToken)
|
if (!hasStartStreamToken)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// From the specification: The stream operator should be followed by \r\n or \n, not just \r.
|
// From the specification: The stream operator should be followed by \r\n or \n, not just \r.
|
||||||
if (!inputBytes.MoveNext())
|
// While the specification demands a \n we have seen files with `garbage` before the actual data
|
||||||
|
do
|
||||||
{
|
{
|
||||||
return false;
|
if (!inputBytes.MoveNext())
|
||||||
}
|
|
||||||
|
|
||||||
// While the specification demands a \n we have seen files with \r only in the wild.
|
|
||||||
var hadWhiteSpace = false;
|
|
||||||
if (inputBytes.CurrentByte == '\r')
|
|
||||||
{
|
|
||||||
hadWhiteSpace = true;
|
|
||||||
inputBytes.MoveNext();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (inputBytes.CurrentByte != '\n')
|
|
||||||
{
|
|
||||||
if (!hadWhiteSpace)
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
} while ((char)inputBytes.CurrentByte != '\n');
|
||||||
inputBytes.Seek(inputBytes.CurrentOffset - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Store where we started reading the first byte of data.
|
// Store where we started reading the first byte of data.
|
||||||
long startDataOffset = inputBytes.CurrentOffset;
|
long startDataOffset = inputBytes.CurrentOffset;
|
||||||
|
|||||||
Reference in New Issue
Block a user