From 587e954bb944ceb75fb0cda35ceae25c70ef8271 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Tue, 2 Aug 2022 14:13:42 +0100 Subject: [PATCH] Merge pull request #9087 from overleaf/jpa-fix-caching [clsi] fix handling of xref tables with non-continuous ids GitOrigin-RevId: 02e00d1963f7547304574d61e441240d086bfe7a --- services/clsi/app/js/XrefParser.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/services/clsi/app/js/XrefParser.js b/services/clsi/app/js/XrefParser.js index db6abf8647..89c782d859 100644 --- a/services/clsi/app/js/XrefParser.js +++ b/services/clsi/app/js/XrefParser.js @@ -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')