mirror of
https://github.com/UglyToad/PdfPig.git
synced 2026-03-10 00:23:29 +08:00
handle the format header being preceded by nonsense
some files seem to have the format header preceded by large amounts of junk but this appears to be valid for chrome and acrobat reader. this change ups the amount of nonsense to be read prior to the version header. also makes parsing of the version header culture invariant which may be related to #85.
This commit is contained in:
@@ -60,14 +60,14 @@
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void HeaderPrecededByJunkNonLenientThrows()
|
||||
public void HeaderPrecededByJunkNonLenientDoesNotThrow()
|
||||
{
|
||||
var scanner = StringBytesTestConverter.Scanner(@"one
|
||||
%PDF-1.2");
|
||||
|
||||
Action action = () => FileHeaderParser.Parse(scanner, false, log);
|
||||
var result = FileHeaderParser.Parse(scanner, false, log);
|
||||
|
||||
Assert.Throws<PdfDocumentFormatException>(action);
|
||||
Assert.Equal(1.2m, result.Version);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -82,14 +82,14 @@
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void HeaderPrecededByTooMuchJunkThrows()
|
||||
public void HeaderPrecededByJunkDoesNotThrow()
|
||||
{
|
||||
var scanner = StringBytesTestConverter.Scanner(@"one two
|
||||
three %PDF-1.6");
|
||||
|
||||
Action action = () => FileHeaderParser.Parse(scanner, true, log);
|
||||
var result = FileHeaderParser.Parse(scanner, true, log);
|
||||
|
||||
Assert.Throws<PdfDocumentFormatException>(action);
|
||||
Assert.Equal(1.6m, result.Version);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
Reference in New Issue
Block a user