1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 06:38:07 +02:00

Catch circular references in /Form XObjects (issue 19800)

For simplicity we will abort /Form XObject parsing *immediately* when encountering a circular reference, rather than letting it continue up until some limit (as e.g. PDFium appears to do), which should be fine since there are never any guarantees if/how *corrupt* PDF documents will render.
This commit is contained in:
Jonas Jenwald 2025-04-11 12:38:13 +02:00
parent 7a94fafd30
commit 1048508dd1
4 changed files with 143 additions and 5 deletions

View file

@ -206,6 +206,7 @@
!issue3928.pdf
!issue8565.pdf
!clippath.pdf
!issue19800.pdf
!issue8795_reduced.pdf
!bug1755507.pdf
!close-path-bug.pdf

90
test/pdfs/issue19800.pdf Normal file
View file

@ -0,0 +1,90 @@
%PDF-1.4
1 0 obj
<<
/Type /Catalog
/Outlines 2 0 R
/Pages 3 0 R
>>
endobj
2 0 obj
<<
/Type /Outlines
/Count 0
>>
endobj
3 0 obj
<<
/Type /Pages
/Kids [ 4 0 R ]
/Count 1
>>
endobj
4 0 obj
<<
/Type /Page
/Parent 3 0 R
/MediaBox [ 0 0 500 300 ]
/Contents 5 0 R
/Resources <<
/ProcSet [ /PDF /Text ]
/XObject << /X1 6 0 R >>
>>
>>
endobj
5 0 obj
<< /Length 24 >>
stream
1 0 0 1 25 25 cm /X1 Do
endstream
endobj
6 0 obj
<< /Subtype /Form
/BBox [0 0 1000 1000]
/Length 61
/Resources <<
/ProcSet [ /PDF /Text ]
/Font << /F1 7 0 R >>
/XObject << /X0 8 0 R >>
>>
>>
stream
BT
/F1 24 Tf
(Hello world) Tj
ET
0.5 0 0 0.5 25 25 cm /X0 Do
endstream
endobj
7 0 obj
<<
/Type /Font
/Subtype /Type1
/Name /F1
/BaseFont /Helvetica
/Encoding /MacRomanEncoding
>>
endobj
8 0 obj
<< /Subtype /Form
/BBox [0 0 1000 1000]
/Length 61
/Resources <<
/ProcSet [ /PDF /Text ]
/Font << /F1 7 0 R >>
/XObject << /X1 6 0 R >>
>>
>>
stream
BT
/F1 24 Tf
(Hello world) Tj
ET
0.5 0 0 0.5 25 25 cm /X1 Do
endstream
endobj
trailer
<<
/Size 8
/Root 1 0 R
>>
%%EOF

View file

@ -6897,6 +6897,20 @@
"lastPage": 2,
"type": "eq"
},
{
"id": "issue19800-eq",
"file": "pdfs/issue19800.pdf",
"md5": "92825d3178196bdd01096c4081609efd",
"rounds": 1,
"type": "eq"
},
{
"id": "issue19800-text",
"file": "pdfs/issue19800.pdf",
"md5": "92825d3178196bdd01096c4081609efd",
"rounds": 1,
"type": "text"
},
{
"id": "issue3438",
"file": "pdfs/issue3438.pdf",