Commit Graph

29 Commits

Author SHA1 Message Date
Richard Flamsholt
57921c7e9b Update test Issue874: Now finds more text on page 1
With the fix for including associated streams, this test now finds more text on the first page. I've verified using Aspose.PDF and by viewing the ErcotFacts.pdf file being tested that yes, it was indeed missing part of the text before.
2025-09-30 18:35:45 +01:00
BobLd
304d7dde5a Use correct font matrix when transforming the width in Type 0 font and fix #1156 2025-09-14 08:22:58 +01:00
Eliot Jones
07df6fd740 read last line of ignore file (#1155)
* read last line of ignore file

- do not cancel other matrix jobs if one test fails
- read all lines of the ignore list even if it doesn't end with a newline
- add ignore list for 0008 and 0009

* support missing object numbers when brute-forcing

the file 10404 (ironically) contains not found references with number 43 0
for its info dictionary. changes brute-force code so that objects can be
entirely missing

* fix test since document is now opened successfully but mediabox is broken
2025-09-13 16:57:35 +02:00
BobLd
d5b97065bd Fix #1148 2025-09-13 10:38:35 +01:00
Eliot Jones
0afe021ad3 move file parsing to single-pass static methods (#1102)
* move file parsing to single-pass static methods

for the file 0002973.pdf in the test corpus we need to completely overhaul
how initial xref parsing is done since we need to locate the xref stream by
brute-force and this is currently broken. i wanted to take this opportunity to
change the logic to be more imperative and less like the pdfbox methods with
instance data and classes.

currently the logic is split between the xref offset validator and parser methods
and we call the validator logic twice, followed by brute-force searching again
in the actual parser. we're going to move to a single method that performs
the following steps:

1. find the first (from the end) occurrence of "startxref" and pull out the location
in bytes. this will also support "startref" since some files in the wild have that
2. go to that offset if found and parse the chain of tables or streams by /prev
reference
3. if any element in step 2 fails then we perform a single brute-force over the
entire file and like pdfbox treat later in file-length xrefs as the ultimate arbiter
of the object positions. while we do this we potentially can capture the actual
object offsets since the xref positions are probably incorrect too.

the aim with this is to avoid as much seeking and re-reading of bytes as
possible. while this won't technically be single-pass it gets us much closer. it
also removes the more strict logic requiring a "startxref" token to exist and be
valid, since we can repair this by brute-force anyway.

we will surface as much information as possible from the static method so that
we could in future support an object explorer ui for pdfs.

this will also be more resilient to invalid xref formats with e.g. comment tokens
or missing newlines.

* move more parsing to the static classes

* plumb through the new parsing results

* plug in new parser and remove old classes, port tests to new classes

* update tests to reflect logic changes

* apply correction when file header has offset

* ignore console runner launch settings

* skip offsets outside of file bounds

* fix parsing tables missing a line break

* use brute forced locations if they're already present

* only treat line breaks and spaces as whitespace for stream content

* address review comments

---------

Co-authored-by: BobLd <38405645+BobLd@users.noreply.github.com>
2025-09-02 19:41:00 +01:00
BobLd
1031dcc221 Prevent StackOverflow in ParseTrailer and fix #1122 2025-08-09 08:46:04 +01:00
BobLd
813d3baa18 Track IndirectReference instead of only ObjectNumber when checking for cycles during indirect reference resolutionv and add test 2025-07-20 19:24:31 +01:00
BobLd
6a50160e65 Prevent RunLengthFilter malicious OOM 2025-06-29 13:57:01 +01:00
BobLd
d9b3891eb3 Do not throw if the Mask dictionary contains a ColorSpace key 2025-05-30 07:53:25 +01:00
BobLd
2b54a546d3 Check for infinite recursion in ObjectLocationProvider.TryGetOffset() and fix #1050 2025-05-28 20:24:31 +01:00
BobLd
5b566b53da Only reset missed attempts count if table is found in CrossReferenceParser.Parse() and fix #1047 2025-05-27 20:57:38 +02:00
BobLd
ca9f70ffb0 Skip control chars in CoreTokenScanner.MoveNext() and fix #1048 2025-05-27 20:57:38 +02:00
BobLd
67d3dde04a Handle TrueType case in CidFontFactory where the font is CFF, implement missing members in PdfCidCompactFontFormatFont and fix #554
Some checks failed
Build and test / build (push) Has been cancelled
Build and test [MacOS] / build (push) Has been cancelled
Run Integration Tests / build (push) Has been cancelled
Nightly Release / tests (push) Has been cancelled
Nightly Release / Check latest commit (push) Has been cancelled
Nightly Release / build_and_publish_nightly (push) Has been cancelled
2025-05-19 00:27:51 +01:00
BobLd
e4d7805a1f Add test to ensure #822 is fixed 2025-05-18 22:32:07 +01:00
BobLd
6911f31b49 Try to repair xref offset by looking for all startxref and fix #1040
Some checks are pending
Build and test / build (push) Waiting to run
Build and test [MacOS] / build (push) Waiting to run
Run Integration Tests / build (push) Waiting to run
2025-05-18 17:32:27 +01:00
BobLd
afdd1f8924 Fix issue #1013 2025-04-20 18:03:04 +01:00
BobLd
74d61bd985 Fix PatternColor Equals() method and fix #1016 2025-03-26 19:48:51 +00:00
BobLd
1b3c7bd355 Better handle integer overflow in DocstrumBoundingBoxes
Some checks failed
Build and test / build (push) Has been cancelled
Run Integration Tests / build (push) Has been cancelled
Nightly Release / tests (push) Has been cancelled
Nightly Release / Check latest commit (push) Has been cancelled
Nightly Release / build_and_publish_nightly (push) Has been cancelled
2025-03-02 18:29:21 +00:00
BobLd
67d8f56366 Do not throw exception when lenient parsing in GetExtendedGraphicsStateDictionary() and improve StackDictionary.TryGetValue() to not throw on empty 2025-03-02 11:51:26 +00:00
BobLd
5a06e1e1cc Assess if transformedGlyphBounds and use transformedPdfBounds as fallback and fix #987
Some checks are pending
Build and test / build (push) Waiting to run
Run Integration Tests / build (push) Waiting to run
2025-02-20 00:11:06 +00:00
BobLd
fdb8835b37 CcittFaxDecodeFilter: do not check for input length, invert bitmap with ref byte and fix #982
Some checks failed
Build and test / build (push) Has been cancelled
Run Integration Tests / build (push) Has been cancelled
2025-02-02 14:26:16 +00:00
BobLd
c4576e4ffa Do not throw error on Pop when stack size is 1 in lenient mode and fix #973 2025-01-19 11:19:32 +00:00
BobLd
50dca593da Do not throw exception when lenient parsing in ON in CrossReferenceParser and fix #959 2024-12-28 12:29:28 +01:00
BobLd
9ad51067b0 Handle odd ligatures names and fix #945 (#946) 2024-11-27 19:44:17 +00:00
BobLd
20804245d0 Handle alternate Unicode name representation cXXX and fix #943 (#944) 2024-11-24 20:24:36 +00:00
BobLd
40af401364 Default page number to 0 in ExplicitDestination when the Dest has no page number and fix #736
Some checks failed
Build and test / build (push) Has been cancelled
Run Integration Tests / build (push) Has been cancelled
Nightly Release / tests (push) Has been cancelled
Nightly Release / Check latest commit (push) Has been cancelled
Nightly Release / build_and_publish_nightly (push) Has been cancelled
2024-10-25 21:28:11 +01:00
BobLd
e10609e4e1 Use pdfScanner in ReadVerticalDisplacements and fix #693 and return 0 in CMap on exception in ReadByte() if useLenientParsing is true and fix #692
Some checks failed
Build and test / build (push) Has been cancelled
Run Integration Tests / build (push) Has been cancelled
2024-10-19 00:29:42 +01:00
BobLd
a258090e1c Fix GetTextOrientation by cleanly checking if rotation is divisible by 90 and fix #913
Some checks failed
Build and test / build (push) Has been cancelled
Run Integration Tests / build (push) Has been cancelled
2024-10-07 20:08:24 +01:00
BobLd
5c168f9cd0 Handle null token in DirectObjectFinder, handle null state in SetNamedGraphicsState(), add and test and fix #874 2024-09-29 16:43:50 +01:00