@file-viewer/assets-ppt 3.3.1 → 3.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +3 -1
- package/README.md +3 -1
- package/README.zh-CN.md +3 -1
- package/package.json +96 -9
- package/viewer/THIRD_PARTY_LICENSES.assets.json +837 -54
- package/viewer/file-viewer-asset-pack.json +20 -31
- package/viewer/vendor/ppt/LICENSE +160 -122
- package/viewer/vendor/ppt/NOTICE.md +30 -0
- package/viewer/vendor/ppt/README.md +86 -0
- package/viewer/vendor/ppt/dist/core/binary.d.ts +31 -0
- package/viewer/vendor/ppt/dist/core/binary.js +102 -0
- package/viewer/vendor/ppt/dist/core/cfb.d.ts +38 -0
- package/viewer/vendor/ppt/dist/core/cfb.js +208 -0
- package/viewer/vendor/ppt/dist/core/crypto.d.ts +12 -0
- package/viewer/vendor/ppt/dist/core/crypto.js +64 -0
- package/viewer/vendor/ppt/dist/core/errors.d.ts +5 -0
- package/viewer/vendor/ppt/dist/core/errors.js +5 -0
- package/viewer/vendor/ppt/dist/core/inflate.d.ts +11 -0
- package/viewer/vendor/ppt/dist/core/inflate.js +337 -0
- package/viewer/vendor/ppt/dist/core/pict.d.ts +14 -0
- package/viewer/vendor/ppt/dist/core/pict.js +472 -0
- package/viewer/vendor/ppt/dist/core/raster.d.ts +7 -0
- package/viewer/vendor/ppt/dist/core/raster.js +101 -0
- package/viewer/vendor/ppt/dist/core/tiff.d.ts +20 -0
- package/viewer/vendor/ppt/dist/core/tiff.js +254 -0
- package/viewer/vendor/ppt/dist/core/utils.d.ts +9 -0
- package/viewer/vendor/ppt/dist/core/utils.js +13 -0
- package/viewer/vendor/ppt/dist/core/vector-font.d.ts +12 -0
- package/viewer/vendor/ppt/dist/core/vector-font.js +29 -0
- package/viewer/vendor/ppt/dist/core/vector.d.ts +19 -0
- package/viewer/vendor/ppt/dist/core/vector.js +1570 -0
- package/viewer/vendor/ppt/dist/core/xml-text.d.ts +1 -0
- package/viewer/vendor/ppt/dist/core/xml-text.js +6 -0
- package/viewer/vendor/ppt/dist/index.d.ts +12 -0
- package/viewer/vendor/ppt/dist/index.js +8 -0
- package/viewer/vendor/ppt/dist/layout/measure.d.ts +15 -0
- package/viewer/vendor/ppt/dist/layout/measure.js +54 -0
- package/viewer/vendor/ppt/dist/layout/text-layout.d.ts +48 -0
- package/viewer/vendor/ppt/dist/layout/text-layout.js +272 -0
- package/viewer/vendor/ppt/dist/manifest.json +13 -0
- package/viewer/vendor/ppt/dist/playback/media.d.ts +11 -0
- package/viewer/vendor/ppt/dist/playback/media.js +37 -0
- package/viewer/vendor/ppt/dist/playback/navigation.d.ts +2 -0
- package/viewer/vendor/ppt/dist/playback/navigation.js +14 -0
- package/viewer/vendor/ppt/dist/playback/timeline.d.ts +47 -0
- package/viewer/vendor/ppt/dist/playback/timeline.js +154 -0
- package/viewer/vendor/ppt/dist/playback/transitions.d.ts +14 -0
- package/viewer/vendor/ppt/dist/playback/transitions.js +41 -0
- package/viewer/vendor/ppt/dist/ppt/animation.d.ts +3 -0
- package/viewer/vendor/ppt/dist/ppt/animation.js +67 -0
- package/viewer/vendor/ppt/dist/ppt/constants.d.ts +72 -0
- package/viewer/vendor/ppt/dist/ppt/constants.js +21 -0
- package/viewer/vendor/ppt/dist/ppt/drawing.d.ts +15 -0
- package/viewer/vendor/ppt/dist/ppt/drawing.js +508 -0
- package/viewer/vendor/ppt/dist/ppt/encryption.d.ts +14 -0
- package/viewer/vendor/ppt/dist/ppt/encryption.js +241 -0
- package/viewer/vendor/ppt/dist/ppt/extras.d.ts +14 -0
- package/viewer/vendor/ppt/dist/ppt/extras.js +225 -0
- package/viewer/vendor/ppt/dist/ppt/geometry.d.ts +29 -0
- package/viewer/vendor/ppt/dist/ppt/geometry.js +448 -0
- package/viewer/vendor/ppt/dist/ppt/headers-footers.d.ts +11 -0
- package/viewer/vendor/ppt/dist/ppt/headers-footers.js +97 -0
- package/viewer/vendor/ppt/dist/ppt/interactions.d.ts +12 -0
- package/viewer/vendor/ppt/dist/ppt/interactions.js +104 -0
- package/viewer/vendor/ppt/dist/ppt/parser.d.ts +12 -0
- package/viewer/vendor/ppt/dist/ppt/parser.js +356 -0
- package/viewer/vendor/ppt/dist/ppt/pictures.d.ts +10 -0
- package/viewer/vendor/ppt/dist/ppt/pictures.js +215 -0
- package/viewer/vendor/ppt/dist/ppt/records.d.ts +13 -0
- package/viewer/vendor/ppt/dist/ppt/records.js +49 -0
- package/viewer/vendor/ppt/dist/ppt/text.d.ts +19 -0
- package/viewer/vendor/ppt/dist/ppt/text.js +789 -0
- package/viewer/vendor/ppt/dist/pptjs.browser.js +9651 -0
- package/viewer/vendor/ppt/dist/pptjs.mjs +9663 -0
- package/viewer/vendor/ppt/dist/pptjs.worker.js +9650 -0
- package/viewer/vendor/ppt/dist/render/effects.d.ts +23 -0
- package/viewer/vendor/ppt/dist/render/effects.js +125 -0
- package/viewer/vendor/ppt/dist/render/fields.d.ts +11 -0
- package/viewer/vendor/ppt/dist/render/fields.js +176 -0
- package/viewer/vendor/ppt/dist/render/geometry.d.ts +11 -0
- package/viewer/vendor/ppt/dist/render/geometry.js +131 -0
- package/viewer/vendor/ppt/dist/render/safe.d.ts +12 -0
- package/viewer/vendor/ppt/dist/render/safe.js +48 -0
- package/viewer/vendor/ppt/dist/render/svg.d.ts +4 -0
- package/viewer/vendor/ppt/dist/render/svg.js +279 -0
- package/viewer/vendor/ppt/dist/render/text.d.ts +9 -0
- package/viewer/vendor/ppt/dist/render/text.js +181 -0
- package/viewer/vendor/ppt/dist/render/three-d.d.ts +32 -0
- package/viewer/vendor/ppt/dist/render/three-d.js +219 -0
- package/viewer/vendor/ppt/dist/render/wordart.d.ts +16 -0
- package/viewer/vendor/ppt/dist/render/wordart.js +214 -0
- package/viewer/vendor/ppt/dist/runtime.d.ts +125 -0
- package/viewer/vendor/ppt/dist/runtime.js +226 -0
- package/viewer/vendor/ppt/dist/types.d.ts +546 -0
- package/viewer/vendor/ppt/dist/types.js +1 -0
- package/viewer/vendor/ppt/dist/viewer.d.ts +3 -0
- package/viewer/vendor/ppt/dist/viewer.js +264 -0
- package/viewer/vendor/ppt/dist/worker-client.d.ts +25 -0
- package/viewer/vendor/ppt/dist/worker-client.js +61 -0
- package/viewer/vendor/ppt/dist/worker.d.ts +1 -0
- package/viewer/vendor/ppt/dist/worker.js +25 -0
- package/viewer/vendor/ppt/package.json +40 -52
- package/viewer/vendor/ppt/NOTICE +0 -229
- package/viewer/vendor/ppt/frame-cache.mjs +0 -731
- package/viewer/vendor/ppt/index.mjs +0 -941
- package/viewer/vendor/ppt/manifest.json +0 -44
- package/viewer/vendor/ppt/ppt-font-cjk.otf +0 -0
- package/viewer/vendor/ppt/ppt-native.wasm +0 -0
- package/viewer/vendor/ppt/worker.mjs +0 -1720
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { PptError } from '../core/errors.js';
|
|
2
|
+
import { concatBytes, equalBytes, little32, passwordBytes, Rc4, sha1 } from '../core/crypto.js';
|
|
3
|
+
const CURRENT_USER = 4086, USER_EDIT = 4085, PERSIST_DIRECTORY = 6002, PERSIST_FULL = 6001, CRYPT_SESSION = 12052;
|
|
4
|
+
const TOKEN_PLAIN = 0xe391c05f, TOKEN_ENCRYPTED = 0xf3d1c4df;
|
|
5
|
+
const view = (bytes) => new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
6
|
+
function fail(code, message, offset) { throw new PptError(code, message, offset); }
|
|
7
|
+
function header(bytes, offset, limit = bytes.length) {
|
|
8
|
+
if (!Number.isSafeInteger(offset) || offset < 0 || offset + 8 > limit || limit > bytes.length)
|
|
9
|
+
fail('ENCRYPTION_RECORD', 'Encrypted PPT record header is outside its stream', offset);
|
|
10
|
+
const v = view(bytes), packed = v.getUint16(offset, true), length = v.getUint32(offset + 4, true), end = offset + 8 + length;
|
|
11
|
+
if (end > limit)
|
|
12
|
+
fail('ENCRYPTION_RECORD', 'Encrypted PPT record length exceeds its available range', offset);
|
|
13
|
+
return { offset, version: packed & 15, instance: packed >>> 4, type: v.getUint16(offset + 2, true), length, end };
|
|
14
|
+
}
|
|
15
|
+
function noOverlaps(spans) { spans.sort((a, b) => a.start - b.start || a.end - b.end); for (let i = 1; i < spans.length; i++)
|
|
16
|
+
if (spans[i].start < spans[i - 1].end)
|
|
17
|
+
fail('ENCRYPTION_OVERLAP', `${spans[i].label} overlaps ${spans[i - 1].label}`, spans[i].start); }
|
|
18
|
+
function blockKey(passwordHash, block, keyBits) { const hash = sha1(concatBytes(passwordHash, little32(block))); if (keyBits === 40) {
|
|
19
|
+
const key = new Uint8Array(16);
|
|
20
|
+
key.set(hash.subarray(0, 5));
|
|
21
|
+
hash.fill(0);
|
|
22
|
+
return key;
|
|
23
|
+
} const key = hash.slice(0, keyBits / 8); hash.fill(0); return key; }
|
|
24
|
+
function cipher(passwordHash, block, keyBits) { const key = blockKey(passwordHash, block, keyBits); try {
|
|
25
|
+
return new Rc4(key);
|
|
26
|
+
}
|
|
27
|
+
finally {
|
|
28
|
+
key.fill(0);
|
|
29
|
+
} }
|
|
30
|
+
function readMetadata(document, record, password) {
|
|
31
|
+
const start = record.offset + 8, end = record.end, v = view(document);
|
|
32
|
+
if (record.version !== 15 || record.instance !== 0 || record.type !== CRYPT_SESSION || start + 12 > end)
|
|
33
|
+
fail('ENCRYPTION_HEADER', 'Invalid CryptSession10Container', record.offset);
|
|
34
|
+
const major = v.getUint16(start, true), minor = v.getUint16(start + 2, true), outerFlags = v.getUint32(start + 4, true), size = v.getUint32(start + 8, true), at = start + 12;
|
|
35
|
+
if (![2, 3, 4].includes(major) || minor !== 2)
|
|
36
|
+
fail('ENCRYPTION_UNSUPPORTED', 'Only Office Binary RC4 CryptoAPI encryption is supported', start);
|
|
37
|
+
if (size < 32 || (size & 1) || at + size + 60 > end)
|
|
38
|
+
fail('ENCRYPTION_HEADER', 'Truncated or invalid CryptoAPI header/verifier', at);
|
|
39
|
+
const flags = v.getUint32(at, true), sizeExtra = v.getUint32(at + 4, true), algorithm = v.getUint32(at + 8, true), hashAlgorithm = v.getUint32(at + 12, true), keyBits = v.getUint32(at + 16, true) || 40, provider = v.getUint32(at + 20, true);
|
|
40
|
+
if (flags !== outerFlags)
|
|
41
|
+
fail('ENCRYPTION_HEADER', 'The two CryptoAPI flag fields disagree', at);
|
|
42
|
+
if (!(flags & 4) || (flags & 0x30) || ![0, 0x6801].includes(algorithm) || ![0, 0x8004].includes(hashAlgorithm) || provider !== 1)
|
|
43
|
+
fail('ENCRYPTION_UNSUPPORTED', 'The PPT cryptographic header does not specify supported RC4/SHA-1 parameters', at);
|
|
44
|
+
if (sizeExtra !== 0 || keyBits < 40 || keyBits > 128 || keyBits % 8)
|
|
45
|
+
fail('ENCRYPTION_HEADER', 'Invalid CryptoAPI key size or reserved length', at);
|
|
46
|
+
if (size > 32) {
|
|
47
|
+
let terminated = false;
|
|
48
|
+
for (let p = at + 32; p + 1 < at + size; p += 2)
|
|
49
|
+
if (v.getUint16(p, true) === 0) {
|
|
50
|
+
terminated = true;
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
if (!terminated)
|
|
54
|
+
fail('ENCRYPTION_HEADER', 'CryptoAPI provider name is not null terminated', at + 32);
|
|
55
|
+
}
|
|
56
|
+
const verifier = at + size;
|
|
57
|
+
if (v.getUint32(verifier, true) !== 16 || v.getUint32(verifier + 36, true) !== 20)
|
|
58
|
+
fail('ENCRYPTION_VERIFIER', 'RC4 CryptoAPI requires a 16-byte salt and 20-byte SHA-1 verifier hash', verifier);
|
|
59
|
+
const passwordData = passwordBytes(password), salt = document.subarray(verifier + 4, verifier + 20), passwordHash = sha1(concatBytes(salt, passwordData));
|
|
60
|
+
passwordData.fill(0);
|
|
61
|
+
const rc4 = cipher(passwordHash, 0, keyBits), plainVerifier = rc4.crypt(document.subarray(verifier + 20, verifier + 36)), plainHash = rc4.crypt(document.subarray(verifier + 40, verifier + 60)), computed = sha1(plainVerifier), valid = equalBytes(plainHash, computed);
|
|
62
|
+
plainVerifier.fill(0);
|
|
63
|
+
plainHash.fill(0);
|
|
64
|
+
computed.fill(0);
|
|
65
|
+
if (!valid) {
|
|
66
|
+
passwordHash.fill(0);
|
|
67
|
+
fail('PASSWORD_INVALID', 'The supplied password does not match this presentation');
|
|
68
|
+
}
|
|
69
|
+
return { passwordHash, keyBits, flags };
|
|
70
|
+
}
|
|
71
|
+
/** Each top-level picture record field starts a fresh block-zero RC4 stream. */
|
|
72
|
+
function decryptPictures(input, metadata, limits, diagnostics) {
|
|
73
|
+
if (input.length > limits.maxStreamBytes)
|
|
74
|
+
fail('LIMIT_STREAM', 'Encrypted Pictures stream exceeds the stream byte limit');
|
|
75
|
+
const output = input.slice();
|
|
76
|
+
let at = 0, count = 0;
|
|
77
|
+
const field = (offset, length, end) => { if (!Number.isSafeInteger(length) || length < 0 || offset < 0 || offset + length > end)
|
|
78
|
+
fail('ENCRYPTION_PICTURE', 'Encrypted picture field exceeds its record', offset); if (length)
|
|
79
|
+
output.set(cipher(metadata.passwordHash, 0, metadata.keyBits).crypt(input.subarray(offset, offset + length)), offset); };
|
|
80
|
+
const rasterInstances = { 0xf01d: [0x46a, 0x46b, 0x6e2, 0x6e3], 0xf02a: [0x46a, 0x46b, 0x6e2, 0x6e3], 0xf01e: [0x6e0, 0x6e1], 0xf01f: [0x7a8, 0x7a9], 0xf029: [0x6e4, 0x6e5] };
|
|
81
|
+
const metafileInstances = { 0xf01a: [0x3d4, 0x3d5], 0xf01b: [0x216, 0x217], 0xf01c: [0x542, 0x543] };
|
|
82
|
+
while (at < input.length) {
|
|
83
|
+
if (++count > limits.maxRecords)
|
|
84
|
+
fail('LIMIT_RECORDS', 'Encrypted picture count exceeds the record budget');
|
|
85
|
+
field(at, 8, input.length);
|
|
86
|
+
const rh = header(output, at), end = rh.end;
|
|
87
|
+
let p = at + 8;
|
|
88
|
+
const known = rasterInstances[rh.type] ?? metafileInstances[rh.type];
|
|
89
|
+
if (known && (!known.includes(rh.instance) || rh.version !== 0))
|
|
90
|
+
fail('ENCRYPTION_PICTURE_UNSUPPORTED', 'An encrypted BLIP uses an unsupported instance or version', at);
|
|
91
|
+
if (known) {
|
|
92
|
+
field(p, 16, end);
|
|
93
|
+
p += 16;
|
|
94
|
+
if (rh.instance & 1) {
|
|
95
|
+
field(p, 16, end);
|
|
96
|
+
p += 16;
|
|
97
|
+
}
|
|
98
|
+
if (metafileInstances[rh.type]) {
|
|
99
|
+
field(p, 34, end);
|
|
100
|
+
const size = view(output).getUint32(p + 28, true);
|
|
101
|
+
p += 34;
|
|
102
|
+
if (size !== end - p)
|
|
103
|
+
fail('ENCRYPTION_PICTURE', 'Metafile stored size disagrees with its encrypted BLIP length', p - 6);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
field(p, 1, end);
|
|
107
|
+
p++;
|
|
108
|
+
}
|
|
109
|
+
field(p, end - p, end);
|
|
110
|
+
}
|
|
111
|
+
else if (rh.type === 0xf007 && rh.version === 2) {
|
|
112
|
+
// FBSE has eleven fixed fields after rh, followed by nameData and one optional embeddedBlip field.
|
|
113
|
+
for (const length of [1, 1, 16, 2, 4, 4, 4, 1, 1, 1, 1]) {
|
|
114
|
+
field(p, length, end);
|
|
115
|
+
p += length;
|
|
116
|
+
}
|
|
117
|
+
const nameLength = output[at + 41];
|
|
118
|
+
if (nameLength & 1)
|
|
119
|
+
fail('ENCRYPTION_PICTURE', 'FBSE name byte count is not even', at + 41);
|
|
120
|
+
field(p, nameLength, end);
|
|
121
|
+
p += nameLength;
|
|
122
|
+
if (p < end) {
|
|
123
|
+
field(p, end - p, end);
|
|
124
|
+
const embedded = header(output, p, end);
|
|
125
|
+
if (embedded.end !== end || embedded.type < 0xf018 || embedded.type > 0xf117)
|
|
126
|
+
fail('ENCRYPTION_PICTURE', 'Invalid embedded BLIP inside encrypted FBSE', p);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
// Record extent remains known, so other pictures can still be recovered safely.
|
|
131
|
+
diagnostics.push({ code: 'ENCRYPTED_PICTURE_UNSUPPORTED', severity: 'warning', message: 'An encrypted picture uses an unknown field layout; its ciphertext payload is retained and is not treated as a decoded image', offset: at, details: { recordType: rh.type, instance: rh.instance } });
|
|
132
|
+
}
|
|
133
|
+
at = end;
|
|
134
|
+
}
|
|
135
|
+
return output;
|
|
136
|
+
}
|
|
137
|
+
/** Return owned plaintext streams, or undefined for an unencrypted presentation. */
|
|
138
|
+
export function decryptPptStreams(cfb, password, limits, diagnostics) {
|
|
139
|
+
const document = cfb.getStream('PowerPoint Document'), currentUser = cfb.getStream('Current User');
|
|
140
|
+
if (!document || !currentUser)
|
|
141
|
+
return undefined;
|
|
142
|
+
if (currentUser.length < 20)
|
|
143
|
+
return undefined;
|
|
144
|
+
const cv = view(currentUser);
|
|
145
|
+
if (cv.getUint16(2, true) !== CURRENT_USER)
|
|
146
|
+
return undefined;
|
|
147
|
+
const token = cv.getUint32(12, true), encryptedToken = token === TOKEN_ENCRYPTED;
|
|
148
|
+
if (encryptedToken && password === undefined)
|
|
149
|
+
fail('ENCRYPTED_PPT', 'This presentation is encrypted; supply its password');
|
|
150
|
+
const editOffset = cv.getUint32(16, true);
|
|
151
|
+
if (editOffset + 40 > document.length) {
|
|
152
|
+
if (encryptedToken)
|
|
153
|
+
fail('ENCRYPTION_RECORD', 'Encrypted UserEditAtom is truncated', editOffset);
|
|
154
|
+
return undefined;
|
|
155
|
+
}
|
|
156
|
+
const dv = view(document), editLength = dv.getUint32(editOffset + 4, true), editType = dv.getUint16(editOffset + 2, true);
|
|
157
|
+
if (editType !== USER_EDIT || editLength < 32) {
|
|
158
|
+
if (encryptedToken)
|
|
159
|
+
fail('ENCRYPTION_HEADER', 'Encrypted presentation has no encryption-session persist reference', editOffset);
|
|
160
|
+
return undefined;
|
|
161
|
+
}
|
|
162
|
+
const cryptoId = dv.getUint32(editOffset + 36, true);
|
|
163
|
+
if (!cryptoId) {
|
|
164
|
+
if (encryptedToken)
|
|
165
|
+
fail('ENCRYPTION_HEADER', 'Encrypted presentation has a zero encryption-session persist reference', editOffset);
|
|
166
|
+
return undefined;
|
|
167
|
+
}
|
|
168
|
+
if (password === undefined)
|
|
169
|
+
fail('ENCRYPTED_PPT', 'This presentation is encrypted; supply its password');
|
|
170
|
+
if (document.length > limits.maxStreamBytes || currentUser.length > limits.maxStreamBytes)
|
|
171
|
+
fail('LIMIT_STREAM', 'Encrypted PPT stream exceeds the configured limit');
|
|
172
|
+
const current = header(currentUser, 0);
|
|
173
|
+
if (current.type !== CURRENT_USER || current.length < 20 || ![TOKEN_ENCRYPTED, TOKEN_PLAIN].includes(token))
|
|
174
|
+
fail('ENCRYPTION_HEADER', 'Invalid encrypted CurrentUserAtom');
|
|
175
|
+
const edit = header(document, editOffset);
|
|
176
|
+
if (edit.version !== 0 || edit.instance !== 0 || edit.length !== 32)
|
|
177
|
+
fail('ENCRYPTION_HEADER', 'Invalid encrypted UserEditAtom', editOffset);
|
|
178
|
+
if (dv.getUint32(editOffset + 16, true) !== 0)
|
|
179
|
+
fail('ENCRYPTION_EDIT_CHAIN', 'An encrypted PPT must have exactly one UserEditAtom', editOffset);
|
|
180
|
+
const dirOffset = dv.getUint32(editOffset + 20, true), directory = header(document, dirOffset);
|
|
181
|
+
if (![PERSIST_DIRECTORY, PERSIST_FULL].includes(directory.type) || directory.version !== 0)
|
|
182
|
+
fail('ENCRYPTION_DIRECTORY', 'Invalid unencrypted persist directory', dirOffset);
|
|
183
|
+
const objects = new Map();
|
|
184
|
+
let at = dirOffset + 8;
|
|
185
|
+
while (at < directory.end) {
|
|
186
|
+
if (at + 4 > directory.end)
|
|
187
|
+
fail('ENCRYPTION_DIRECTORY', 'Truncated encrypted-document persist entry', at);
|
|
188
|
+
const packed = dv.getUint32(at, true), start = packed & 0xfffff, count = packed >>> 20;
|
|
189
|
+
at += 4;
|
|
190
|
+
if (!start || !count || start + count > 0x100000 || at + count * 4 > directory.end)
|
|
191
|
+
fail('ENCRYPTION_DIRECTORY', 'Invalid encrypted-document persist range', at - 4);
|
|
192
|
+
if (objects.size + count > limits.maxRecords)
|
|
193
|
+
fail('LIMIT_RECORDS', 'Encrypted persist directory exceeds the record budget');
|
|
194
|
+
for (let i = 0; i < count; i++) {
|
|
195
|
+
const id = start + i, offset = dv.getUint32(at + i * 4, true);
|
|
196
|
+
if (objects.has(id) || offset + 8 > document.length)
|
|
197
|
+
fail('ENCRYPTION_DIRECTORY', 'Duplicate persist ID or invalid encrypted-object offset', at + i * 4);
|
|
198
|
+
objects.set(id, offset);
|
|
199
|
+
}
|
|
200
|
+
at += count * 4;
|
|
201
|
+
}
|
|
202
|
+
const cryptOffset = objects.get(cryptoId);
|
|
203
|
+
if (cryptOffset === undefined)
|
|
204
|
+
fail('ENCRYPTION_HEADER', 'Encryption-session persist object is missing');
|
|
205
|
+
const crypt = header(document, cryptOffset), protectedSpans = [{ start: editOffset, end: edit.end, label: 'UserEditAtom' }, { start: dirOffset, end: directory.end, label: 'PersistDirectoryAtom' }, { start: cryptOffset, end: crypt.end, label: 'CryptSession10Container' }];
|
|
206
|
+
noOverlaps([...protectedSpans]);
|
|
207
|
+
const offsets = [...objects].map(([id, offset]) => ({ id, offset })).sort((a, b) => a.offset - b.offset);
|
|
208
|
+
for (let i = 1; i < offsets.length; i++)
|
|
209
|
+
if (offsets[i].offset === offsets[i - 1].offset)
|
|
210
|
+
fail('ENCRYPTION_OVERLAP', 'Different persist IDs alias the same encrypted bytes', offsets[i].offset);
|
|
211
|
+
const metadata = readMetadata(document, crypt, password);
|
|
212
|
+
try {
|
|
213
|
+
const spans = [...protectedSpans], decrypted = [];
|
|
214
|
+
// Authenticate the password first, then decrypt only eight bytes per object to establish all ranges.
|
|
215
|
+
for (const entry of offsets) {
|
|
216
|
+
if (entry.id === cryptoId)
|
|
217
|
+
continue;
|
|
218
|
+
const first = cipher(metadata.passwordHash, entry.id, metadata.keyBits).crypt(document.subarray(entry.offset, entry.offset + 8)), length = view(first).getUint32(4, true), end = entry.offset + 8 + length;
|
|
219
|
+
if (end > document.length)
|
|
220
|
+
fail('ENCRYPTION_RECORD', 'Decrypted persist length exceeds its stream', entry.offset);
|
|
221
|
+
spans.push({ start: entry.offset, end, label: `Persist object ${entry.id}` });
|
|
222
|
+
decrypted.push({ id: entry.id, offset: entry.offset, length });
|
|
223
|
+
}
|
|
224
|
+
noOverlaps(spans);
|
|
225
|
+
const output = document.slice();
|
|
226
|
+
for (const object of decrypted)
|
|
227
|
+
output.set(cipher(metadata.passwordHash, object.id, metadata.keyBits).crypt(document.subarray(object.offset, object.offset + 8 + object.length)), object.offset);
|
|
228
|
+
// These two in-memory flags let the ordinary parser consume the authenticated plaintext.
|
|
229
|
+
view(output).setUint32(editOffset + 36, 0, true);
|
|
230
|
+
const user = currentUser.slice();
|
|
231
|
+
view(user).setUint32(12, TOKEN_PLAIN, true);
|
|
232
|
+
const pictures = decryptPictures(cfb.getStream('Pictures') ?? new Uint8Array(), metadata, limits, diagnostics);
|
|
233
|
+
if (!(metadata.flags & 8))
|
|
234
|
+
diagnostics.push({ code: 'ENCRYPTED_METADATA_UNSUPPORTED', severity: 'info', message: 'Encrypted summary properties are retained in the input file and are not exposed as document metadata' });
|
|
235
|
+
diagnostics.push({ code: 'PPT_DECRYPTED', severity: 'info', message: 'The presentation was decrypted with the supplied password using RC4 CryptoAPI', details: { keyBits: metadata.keyBits } });
|
|
236
|
+
return { document: output, currentUser: user, pictures };
|
|
237
|
+
}
|
|
238
|
+
finally {
|
|
239
|
+
metadata.passwordHash.fill(0);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Diagnostic, ParseLimits, PptAsset, PptDocumentExtras, RecordNode } from '../types.js';
|
|
2
|
+
export interface ParsedExtras extends PptDocumentExtras {
|
|
3
|
+
assets: PptAsset[];
|
|
4
|
+
hyperlinkTargets: Map<number, string>;
|
|
5
|
+
additionalRecordCount: number;
|
|
6
|
+
}
|
|
7
|
+
/** A safe clickable target; relative/local file destinations stay metadata-only. */
|
|
8
|
+
export declare function safeHyperlinkTarget(target: string, location?: string): string | undefined;
|
|
9
|
+
/** Extracts data without external retrieval, macro execution, media playback or OLE activation. */
|
|
10
|
+
export declare function parseDocumentExtras(records: readonly RecordNode[], bytes: Uint8Array, limits: ParseLimits, diagnostics: Diagnostic[]): ParsedExtras;
|
|
11
|
+
/** Call on an individual slide to retain its comments and animation inventory. */
|
|
12
|
+
export declare function parseSlideExtras(records: readonly RecordNode[], bytes: Uint8Array, limits: ParseLimits, diagnostics: Diagnostic[], slideId: number): ParsedExtras;
|
|
13
|
+
/** [MS-PPT] 2.10.34–36: caller resolves the OLE object's storagePersistId first. */
|
|
14
|
+
export declare function extractOleStorage(record: RecordNode, bytes: Uint8Array, maxBytes: number, diagnostics: Diagnostic[]): PptAsset | undefined;
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { PptError } from '../core/errors.js';
|
|
2
|
+
import { trimTrailingNulls } from '../core/utils.js';
|
|
3
|
+
import { inflateZlib } from '../core/inflate.js';
|
|
4
|
+
import { readRecords } from './records.js';
|
|
5
|
+
/** Normative record IDs from [MS-PPT] 2.13.24. */
|
|
6
|
+
const R = { CString: 0x0FBA, Hyperlink: 0x0FD7, HyperlinkAtom: 0x0FD3, Sound: 0x07E6, SoundData: 0x07E7, MediaAtom: 0x1004, Video: 0x1005, Midi: 0x100D, Cd: 0x100E, WavEmbedded: 0x100F, WavLinked: 0x1010, WavEmbeddedAtom: 0x1013, OleAtom: 0x0FC3, OleEmbedded: 0x0FCC, OleLinked: 0x0FCE, OleControl: 0x0FEE, Comment: 0x2EE0, CommentAtom: 0x2EE1, ProgBinaryTag: 0x138A, BinaryTagData: 0x138B, AnimationInfo: 0x1014, AnimationInfoAtom: 0x0FF1 };
|
|
7
|
+
const utf16 = new TextDecoder('utf-16le');
|
|
8
|
+
function warning(ctx, code, message, node) { ctx.diagnostics.push({ code, severity: 'warning', message, offset: node.offset }); }
|
|
9
|
+
function string(ctx, node) {
|
|
10
|
+
if (!node)
|
|
11
|
+
return '';
|
|
12
|
+
if (node.length % 2)
|
|
13
|
+
warning(ctx, 'EXTRA_STRING_LENGTH', 'UTF-16 metadata string has an odd byte length', node);
|
|
14
|
+
const length = Math.floor(node.length / 2);
|
|
15
|
+
ctx.textLength += length;
|
|
16
|
+
if (ctx.textLength > ctx.limits.maxTextLength)
|
|
17
|
+
throw new PptError('LIMIT_TEXT', 'Metadata text exceeds the configured limit', node.offset);
|
|
18
|
+
return trimTrailingNulls(utf16.decode(ctx.bytes.subarray(node.dataOffset, node.dataOffset + length * 2)));
|
|
19
|
+
}
|
|
20
|
+
function cstring(ctx, node, instance) { return string(ctx, node.children.find(r => r.type === R.CString && r.instance === instance)); }
|
|
21
|
+
function view(ctx, node) { return new DataView(ctx.bytes.buffer, ctx.bytes.byteOffset + node.dataOffset, node.length); }
|
|
22
|
+
function* extendedRecords(nodes, ctx, depth = 0) {
|
|
23
|
+
if (depth > ctx.limits.maxDepth)
|
|
24
|
+
throw new PptError('LIMIT_DEPTH', 'Metadata extension nesting exceeds the configured limit');
|
|
25
|
+
for (const node of nodes) {
|
|
26
|
+
yield node;
|
|
27
|
+
if (node.type === R.ProgBinaryTag) {
|
|
28
|
+
const name = cstring(ctx, node, 0), blob = node.children.find(r => r.type === R.BinaryTagData);
|
|
29
|
+
if (blob && name === '___PPT10') {
|
|
30
|
+
try {
|
|
31
|
+
const extra = readRecords(ctx.recordContext, blob.dataOffset, blob.end, depth + 1);
|
|
32
|
+
yield* extendedRecords(extra, ctx, depth + 1);
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
if (error instanceof PptError && error.code.startsWith('LIMIT_'))
|
|
36
|
+
throw error;
|
|
37
|
+
warning(ctx, 'PROGRAM_TAG_INVALID', 'The ___PPT10 record sequence is malformed and could not be fully decoded', blob);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
else if (blob)
|
|
41
|
+
warning(ctx, 'PROGRAM_TAG_UNSUPPORTED', `Programmable tag ${name || '(unnamed)'} is not decoded by this build`, blob);
|
|
42
|
+
}
|
|
43
|
+
if (node.children.length)
|
|
44
|
+
yield* extendedRecords(node.children, ctx, depth + 1);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/** A safe clickable target; relative/local file destinations stay metadata-only. */
|
|
48
|
+
export function safeHyperlinkTarget(target, location) {
|
|
49
|
+
if (/[\u0000-\u001f\u007f]/.test(target))
|
|
50
|
+
return undefined;
|
|
51
|
+
const value = target.trim();
|
|
52
|
+
if (/^https?:\/\//i.test(value)) {
|
|
53
|
+
try {
|
|
54
|
+
const url = new URL(value);
|
|
55
|
+
if (!url.hostname)
|
|
56
|
+
return undefined;
|
|
57
|
+
if (location)
|
|
58
|
+
url.hash = location;
|
|
59
|
+
return url.href;
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (/^(?:mailto:|tel:|#)/i.test(value) && !/[\s]/.test(value))
|
|
66
|
+
return value;
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
function hyperlink(node, ctx) {
|
|
70
|
+
const atom = node.children.find(r => r.type === R.HyperlinkAtom);
|
|
71
|
+
if (!atom || atom.length < 4) {
|
|
72
|
+
warning(ctx, 'HYPERLINK_ATOM', 'Hyperlink identifier is missing', node);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const id = view(ctx, atom).getUint32(0, true), target = cstring(ctx, node, 1), location = cstring(ctx, node, 3), friendlyName = cstring(ctx, node, 0);
|
|
76
|
+
const href = safeHyperlinkTarget(target, location);
|
|
77
|
+
if (!href && (target || location))
|
|
78
|
+
warning(ctx, target ? 'HYPERLINK_BLOCKED' : 'INTERNAL_LINK_UNRESOLVED', target ? 'A local, relative or unsafe hyperlink is preserved as metadata without an active link' : 'An internal slide destination is preserved but has no resolved navigation target', node);
|
|
79
|
+
return { id, friendlyName: friendlyName || undefined, target, location: location || undefined, href, blocked: !href, sourceOffset: node.offset };
|
|
80
|
+
}
|
|
81
|
+
function soundMime(bytes, extension) { const ascii = (offset, count) => String.fromCharCode(...bytes.subarray(offset, offset + count)); if (ascii(0, 4) === 'RIFF' && ascii(8, 4) === 'WAVE')
|
|
82
|
+
return 'audio/wav'; if (ascii(0, 4) === 'FORM' && ['AIFF', 'AIFC'].includes(ascii(8, 4)))
|
|
83
|
+
return 'audio/aiff'; if (['.wav', 'wave'].includes(extension.toLowerCase()))
|
|
84
|
+
return 'audio/wav'; if (['.aif', 'aiff'].includes(extension.toLowerCase()))
|
|
85
|
+
return 'audio/aiff'; return 'application/octet-stream'; }
|
|
86
|
+
function parseSound(node, ctx, assets, remaining) {
|
|
87
|
+
const name = cstring(ctx, node, 0), extension = cstring(ctx, node, 1), idText = cstring(ctx, node, 2), builtin = cstring(ctx, node, 3), data = node.children.find(r => r.type === R.SoundData);
|
|
88
|
+
const id = Number(idText);
|
|
89
|
+
if (!/^\d+$/.test(idText) || !Number.isSafeInteger(id) || id <= 0) {
|
|
90
|
+
warning(ctx, 'SOUND_ID', 'Embedded sound has an invalid identifier', node);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const result = { id, name, extension: extension || undefined, builtinId: /^\d+$/.test(builtin) ? Number(builtin) : undefined, byteLength: data?.length ?? 0, sourceOffset: node.offset };
|
|
94
|
+
if (data) {
|
|
95
|
+
if (data.length > remaining)
|
|
96
|
+
throw new PptError('LIMIT_ASSETS', 'Embedded sound data exceeds the configured asset limit', data.offset);
|
|
97
|
+
const bytes = new Uint8Array(ctx.bytes.subarray(data.dataOffset, data.end)), mimeType = soundMime(bytes, extension);
|
|
98
|
+
result.assetId = `sound-${id}-${node.offset}`;
|
|
99
|
+
assets.push({ id: result.assetId, mimeType, bytes, sourceOffset: data.offset, unsupported: mimeType === 'application/octet-stream' });
|
|
100
|
+
}
|
|
101
|
+
else
|
|
102
|
+
warning(ctx, 'SOUND_DATA_MISSING', 'Embedded sound has no audio bytes', node);
|
|
103
|
+
return result;
|
|
104
|
+
}
|
|
105
|
+
function parseMedia(node, ctx) {
|
|
106
|
+
const atom = node.children.find(r => r.type === R.MediaAtom);
|
|
107
|
+
if (!atom || atom.length < 8) {
|
|
108
|
+
warning(ctx, 'MEDIA_ATOM', 'External media identifier or flags are missing', node);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const v = view(ctx, atom), flags = v.getUint16(4, true), wav = node.children.find(r => r.type === R.WavEmbeddedAtom), wv = wav && wav.length >= 8 ? view(ctx, wav) : undefined;
|
|
112
|
+
const item = { id: v.getUint32(0, true), kind: node.type === R.Video ? 'video' : 'audio', sourceRecordType: node.type, path: cstring(ctx, node, 0) || undefined, soundId: wv?.getUint32(0, true), durationMs: wv ? Math.max(0, wv.getInt32(4, true)) : undefined, loop: !!(flags & 1), rewind: !!(flags & 2), narration: !!(flags & 4), sourceOffset: node.offset };
|
|
113
|
+
if (!item.soundId)
|
|
114
|
+
warning(ctx, 'MEDIA_EXTERNAL_SOURCE', 'External media is retained as metadata; its file path is not fetched by the preview', node);
|
|
115
|
+
return item;
|
|
116
|
+
}
|
|
117
|
+
function parseOle(node, ctx) {
|
|
118
|
+
const atom = node.children.find(r => r.type === R.OleAtom);
|
|
119
|
+
if (!atom || atom.length < 24) {
|
|
120
|
+
warning(ctx, 'OLE_ATOM', 'OLE object metadata is missing or truncated', node);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const v = view(ctx, atom);
|
|
124
|
+
warning(ctx, 'OLE_METADATA_ONLY', 'OLE application metadata is retained; only a saved picture preview can be displayed, and no embedded application is executed', node);
|
|
125
|
+
return { id: v.getUint32(8, true), type: v.getUint32(4, true), subType: v.getUint32(12, true), drawAspect: v.getUint32(0, true), storagePersistId: v.getUint32(16, true), menuName: cstring(ctx, node, 1) || undefined, progId: cstring(ctx, node, 2) || undefined, clipboardName: cstring(ctx, node, 3) || undefined, sourceOffset: node.offset };
|
|
126
|
+
}
|
|
127
|
+
function dateTime(v, offset) {
|
|
128
|
+
const year = v.getUint16(offset, true), month = v.getUint16(offset + 2, true), day = v.getUint16(offset + 6, true), hour = v.getUint16(offset + 8, true), minute = v.getUint16(offset + 10, true), second = v.getUint16(offset + 12, true), ms = v.getUint16(offset + 14, true);
|
|
129
|
+
if (!year || month < 1 || month > 12 || day < 1 || day > 31 || hour > 23 || minute > 59 || second > 59 || ms > 999)
|
|
130
|
+
return undefined;
|
|
131
|
+
// SYSTEMTIME carries no zone. Preserve a local date-time instead of inventing UTC.
|
|
132
|
+
const p = (n, length = 2) => String(n).padStart(length, '0');
|
|
133
|
+
return `${p(year, 4)}-${p(month)}-${p(day)}T${p(hour)}:${p(minute)}:${p(second)}.${p(ms, 3)}`;
|
|
134
|
+
}
|
|
135
|
+
function parseComment(node, ctx) {
|
|
136
|
+
const atom = node.children.find(r => r.type === R.CommentAtom);
|
|
137
|
+
if (!atom || atom.length < 28) {
|
|
138
|
+
warning(ctx, 'COMMENT_ATOM', 'Presentation comment position or date is missing', node);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const v = view(ctx, atom);
|
|
142
|
+
return { index: v.getInt32(0, true), author: cstring(ctx, node, 0), text: cstring(ctx, node, 1), initials: cstring(ctx, node, 2), createdAt: dateTime(v, 4), position: { x: v.getInt32(20, true) / 6, y: v.getInt32(24, true) / 6 }, sourceOffset: node.offset };
|
|
143
|
+
}
|
|
144
|
+
/** Extracts data without external retrieval, macro execution, media playback or OLE activation. */
|
|
145
|
+
export function parseDocumentExtras(records, bytes, limits, diagnostics) {
|
|
146
|
+
const ctx = { bytes, limits, diagnostics, textLength: 0, recordContext: { bytes, limits, diagnostics, count: 0 } };
|
|
147
|
+
const result = { hyperlinks: [], hyperlinkTargets: new Map(), sounds: [], media: [], oleObjects: [], comments: [], assets: [], animationRecordTypes: [], additionalRecordCount: 0 };
|
|
148
|
+
const ids = new Set(), soundIds = new Set(), animations = new Set();
|
|
149
|
+
let assetBytes = 0;
|
|
150
|
+
for (const record of extendedRecords(records, ctx)) {
|
|
151
|
+
if (record.type === R.Hyperlink) {
|
|
152
|
+
const item = hyperlink(record, ctx);
|
|
153
|
+
if (item) {
|
|
154
|
+
if (ids.has(item.id)) {
|
|
155
|
+
warning(ctx, 'EXTERNAL_ID_DUPLICATE', 'Duplicate external-object/hyperlink identifier was ignored', record);
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
ids.add(item.id);
|
|
159
|
+
result.hyperlinks.push(item);
|
|
160
|
+
if (item.href)
|
|
161
|
+
result.hyperlinkTargets.set(item.id, item.href);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
else if (record.type === R.Sound) {
|
|
165
|
+
const item = parseSound(record, ctx, result.assets, limits.maxAssetBytes - assetBytes);
|
|
166
|
+
if (item) {
|
|
167
|
+
if (soundIds.has(item.id))
|
|
168
|
+
warning(ctx, 'SOUND_ID_DUPLICATE', 'Duplicate sound identifier retained with a unique asset identifier', record);
|
|
169
|
+
soundIds.add(item.id);
|
|
170
|
+
result.sounds.push(item);
|
|
171
|
+
assetBytes += item.byteLength;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
else if ([R.Video, R.Midi, R.Cd, R.WavEmbedded, R.WavLinked].includes(record.type)) {
|
|
175
|
+
const item = parseMedia(record, ctx);
|
|
176
|
+
if (item)
|
|
177
|
+
result.media.push(item);
|
|
178
|
+
}
|
|
179
|
+
else if ([R.OleEmbedded, R.OleLinked, R.OleControl].includes(record.type)) {
|
|
180
|
+
const item = parseOle(record, ctx);
|
|
181
|
+
if (item)
|
|
182
|
+
result.oleObjects.push(item);
|
|
183
|
+
}
|
|
184
|
+
else if (record.type === R.Comment) {
|
|
185
|
+
const item = parseComment(record, ctx);
|
|
186
|
+
if (item)
|
|
187
|
+
result.comments.push(item);
|
|
188
|
+
}
|
|
189
|
+
if (record.type === R.AnimationInfo || record.type === R.AnimationInfoAtom || record.type >= 0xF125 && record.type <= 0xF145 || record.type >= 0x2B02 && record.type <= 0x2B0D)
|
|
190
|
+
animations.add(record.type);
|
|
191
|
+
}
|
|
192
|
+
result.animationRecordTypes = [...animations];
|
|
193
|
+
result.additionalRecordCount = ctx.recordContext.count;
|
|
194
|
+
if (animations.size)
|
|
195
|
+
diagnostics.push({ code: 'ANIMATION_RECORDS_PRESENT', severity: 'info', message: 'Animation/build records were identified; supported effects are mapped separately to the playback timeline', details: { recordTypes: [...animations] } });
|
|
196
|
+
return result;
|
|
197
|
+
}
|
|
198
|
+
/** Call on an individual slide to retain its comments and animation inventory. */
|
|
199
|
+
export function parseSlideExtras(records, bytes, limits, diagnostics, slideId) { const start = diagnostics.length, result = parseDocumentExtras(records, bytes, limits, diagnostics); for (const c of result.comments)
|
|
200
|
+
c.slideId = slideId; for (let i = start; i < diagnostics.length; i++)
|
|
201
|
+
diagnostics[i].slideId = slideId; return result; }
|
|
202
|
+
/** [MS-PPT] 2.10.34–36: caller resolves the OLE object's storagePersistId first. */
|
|
203
|
+
export function extractOleStorage(record, bytes, maxBytes, diagnostics) {
|
|
204
|
+
if (record.type !== 0x1011 || record.version !== 0 || record.instance !== 0 && record.instance !== 1) {
|
|
205
|
+
diagnostics.push({ code: 'OLE_STORAGE_TYPE', severity: 'warning', message: 'OLE storage reference has an unsupported record type', offset: record.offset });
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
let result = null;
|
|
209
|
+
if (record.instance === 0) {
|
|
210
|
+
if (record.length > maxBytes)
|
|
211
|
+
throw new PptError('LIMIT_ASSETS', 'OLE storage exceeds the remaining asset limit', record.offset);
|
|
212
|
+
result = new Uint8Array(bytes.subarray(record.dataOffset, record.end));
|
|
213
|
+
}
|
|
214
|
+
else if (record.length >= 4) {
|
|
215
|
+
const size = new DataView(bytes.buffer, bytes.byteOffset + record.dataOffset, 4).getUint32(0, true);
|
|
216
|
+
if (size > maxBytes)
|
|
217
|
+
throw new PptError('LIMIT_ASSETS', 'Decompressed OLE storage exceeds the remaining asset limit', record.offset);
|
|
218
|
+
result = inflateZlib(bytes.subarray(record.dataOffset + 4, record.end), size, maxBytes);
|
|
219
|
+
}
|
|
220
|
+
if (!result) {
|
|
221
|
+
diagnostics.push({ code: 'OLE_STORAGE_INVALID', severity: 'warning', message: 'OLE storage is truncated or its zlib payload could not be decoded', offset: record.offset });
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
return { id: `ole-storage-${record.offset}`, mimeType: 'application/x-ole-storage', bytes: result, sourceOffset: record.offset, unsupported: true };
|
|
225
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Diagnostic, PptPathPart, Rect } from '../types.js';
|
|
2
|
+
export interface OfficeArray {
|
|
3
|
+
view: DataView;
|
|
4
|
+
count: number;
|
|
5
|
+
size: number;
|
|
6
|
+
}
|
|
7
|
+
/** An OfficeArt complex array includes its six-byte IMsoArray header. */
|
|
8
|
+
export declare function officeArray(bytes: Uint8Array): OfficeArray | undefined;
|
|
9
|
+
/** Evaluate the 17 SG operations; references are limited to preceding guides. */
|
|
10
|
+
export declare function evaluateGuides(bytes: Uint8Array, values: Map<number, number>, geometry: Rect, bounds?: Rect): number[] | undefined;
|
|
11
|
+
/** Stored vertices, SG guides, common path opcodes and elliptical arc escapes. */
|
|
12
|
+
export declare function customGeometry(values: Map<number, number>, complex: Map<number, Uint8Array>, diagnostics: Diagnostic[], shapeId: number, offset: number, bounds?: Rect): {
|
|
13
|
+
path?: string;
|
|
14
|
+
pathParts?: PptPathPart[];
|
|
15
|
+
pathBounds?: Rect;
|
|
16
|
+
noFill?: boolean;
|
|
17
|
+
noLine?: boolean;
|
|
18
|
+
};
|
|
19
|
+
export interface AdjustedPresetGeometry {
|
|
20
|
+
path: string;
|
|
21
|
+
pathBounds: Rect;
|
|
22
|
+
approximate: boolean;
|
|
23
|
+
}
|
|
24
|
+
/** Saved adjustment handles use the 21,600-unit OfficeArt geometry space.
|
|
25
|
+
* Right-arrow construction is independently described by Microsoft's VML handles example.
|
|
26
|
+
* Other analytic envelopes remain explicitly labelled where their complete Office recipe
|
|
27
|
+
* is not published in MS-ODRAW. A stored pVertices/pGuides path always takes precedence.
|
|
28
|
+
*/
|
|
29
|
+
export declare function adjustedPresetGeometry(preset: number, values: Map<number, number>, bounds: Rect): AdjustedPresetGeometry | undefined;
|