mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-08-20 04:31:25 +08:00
address bugs and add tests
This commit is contained in:
parent
7134032188
commit
8176903b4e
File diff suppressed because it is too large
Load Diff
@ -400,7 +400,7 @@
|
||||
// Token is at end of stream or is followed by whitespace
|
||||
if (!inputBytes.MoveNext() || ReadHelper.IsWhitespace(inputBytes.CurrentByte))
|
||||
{
|
||||
var location = inputBytes.CurrentOffset - EndstreamBytes.Length;
|
||||
var location = inputBytes.CurrentOffset - EndstreamBytes.Length - 1;
|
||||
endLocations.Push(new EndLoc(true, location, !isEndData));
|
||||
isEndData = true;
|
||||
|
||||
@ -412,6 +412,12 @@
|
||||
endStreamPosition = 0;
|
||||
commonPartPosition = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
endStreamPosition = 0;
|
||||
commonPartPosition = 0;
|
||||
isEndData = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (inputBytes.CurrentByte == objPart[endObjPosition])
|
||||
@ -444,6 +450,10 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (inputBytes.CurrentByte == endWordPart[0])
|
||||
{
|
||||
commonPartPosition = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We were reading 'end' but then we had a character mismatch.
|
||||
@ -488,20 +498,22 @@
|
||||
|
||||
var dataLength = endLoc.Offset - startDataOffset;
|
||||
|
||||
// 3 characters, 'e', '\n' and possibly '\r'
|
||||
inputBytes.Seek(endLoc.Offset - 3);
|
||||
inputBytes.MoveNext();
|
||||
inputBytes.Seek(endLoc.Offset - 1);
|
||||
|
||||
if (inputBytes.CurrentByte == '\r')
|
||||
var adjustment = 0;
|
||||
bool isWhitespace;
|
||||
do
|
||||
{
|
||||
dataLength -= 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
dataLength -= 2;
|
||||
}
|
||||
inputBytes.MoveNext();
|
||||
isWhitespace = ReadHelper.IsWhitespace(inputBytes.CurrentByte);
|
||||
if (isWhitespace)
|
||||
{
|
||||
adjustment++;
|
||||
}
|
||||
inputBytes.Seek(endLoc.Offset - 1 - adjustment);
|
||||
} while (isWhitespace);
|
||||
|
||||
Memory<byte> data = new byte[dataLength];
|
||||
Memory<byte> data = new byte[dataLength - adjustment];
|
||||
|
||||
inputBytes.Seek(streamDataStart);
|
||||
inputBytes.Read(data.Span);
|
||||
|
Loading…
Reference in New Issue
Block a user