Merge pull request #9087 from overleaf/jpa-fix-caching

[clsi] fix handling of xref tables with non-continuous ids

GitOrigin-RevId: 02e00d1963f7547304574d61e441240d086bfe7a
This commit is contained in:
Brian Gough 2022-08-02 14:13:42 +01:00 committed by Copybot
parent da3d4fd4f5
commit 587e954bb9

View file

@ -37,16 +37,15 @@ async function parseXrefTable(filePath, pdfFileSize) {
// put an upper limit of 10^10 on all the matched numbers for safety
// ignore the generation id in "id/gen"
// in a linearized pdf all objects must have generation number 0
/^(\d{1,9})\/\d{1,9}: uncompressed; offset = (\d{1,9})$/gm
/^\d{1,9}\/\d{1,9}: uncompressed; offset = (\d{1,9})$/gm
)
// include a zero-index object for backwards compatibility with
// our existing xref table parsing code
const xRefEntries = [{ offset: 0 }]
// extract all the xref table entries
for (const match of matches) {
const id = parseInt(match[1], 10) // must convert from strings to integers
const offset = parseInt(match[2], 10)
xRefEntries[id] = { offset, uncompressed: true }
const offset = parseInt(match[1], 10)
xRefEntries.push({ offset, uncompressed: true })
}
if (xRefEntries.length === 1) {
throw new NoXrefTableError('xref file has no objects')