fix(pdf): bounded attachment extraction by byte scan — no pdf-lib parse on import, export without object streams (BLK-009)
This commit is contained in:
1 parent
62b8a43e09
commit
60ee71208f
14 files changed
+1054
-198
No files matched your search
@@ -16,11 +16,12 @@ beforeAll(async () => {
|
||||
sheet = await loadTestSheet()
|
||||
})
|
||||
|
||||
/** Saved like the export (no object streams, BLK-009) so the keyword stamp is in clear. */
|
||||
async function pdfWithoutAttachment(keywords?: string[]): Promise<Uint8Array> {
|
||||
const doc = await PDFDocument.create()
|
||||
doc.addPage()
|
||||
if (keywords) doc.setKeywords(keywords)
|
||||
return doc.save()
|
||||
return doc.save({ useObjectStreams: false })
|
||||
}
|
||||
|
||||
async function rejectsWith(bytes: Uint8Array, kind: string): Promise<void> {
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
* and on a Step 6 envelope (archive header line).
|
||||
*/
|
||||
import { describe, it, expect, beforeAll } from 'vitest'
|
||||
import { PDFDocument } from 'pdf-lib'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { dirname, resolve } from 'node:path'
|
||||
@@ -48,8 +47,7 @@ beforeAll(async () => {
|
||||
describe('compareReport on the frozen v2 archive PDF', () => {
|
||||
it('shows every legacy zone and finding next to its canonical target', async () => {
|
||||
const bytes = readFileSync(resolve(HERE, '../fixtures/report-v2.full.pdf'))
|
||||
const pdf = await PDFDocument.load(new Uint8Array(bytes))
|
||||
const raw = await readAttachedDocument(pdf)
|
||||
const raw = await readAttachedDocument(new Uint8Array(bytes))
|
||||
const c = compareRaw(raw)
|
||||
const lines = renderComparison('full.pdf', c)
|
||||
expect(c.source).toBe('v2')
|
||||
|
||||
Reference in new issue
Block a user