@shbernal/ts-xlsx 3.2.2-next.25.g7699212 → 3.2.2-next.26.gf63f249
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/dist/vba/cfb-format.d.ts
CHANGED
|
@@ -76,3 +76,9 @@ export declare const MAX_NAME_CHARS = 31;
|
|
|
76
76
|
* name differently would read as missing a stream it has.
|
|
77
77
|
*/
|
|
78
78
|
export declare function sameEntryName(a: string, b: string): boolean;
|
|
79
|
+
/**
|
|
80
|
+
* A key equal for exactly the names {@link sameEntryName} treats as one entry, so a set of them can
|
|
81
|
+
* catch a collision without comparing every pair. The length is part of the key because uppercasing
|
|
82
|
+
* can change it (`ß` becomes `SS`), and 2.6.4 compares the original lengths first.
|
|
83
|
+
*/
|
|
84
|
+
export declare function entryNameKey(name: string): string;
|
package/dist/vba/cfb-format.js
CHANGED
|
@@ -42,5 +42,8 @@ export const MINI_STREAM_CUTOFF = 4096;
|
|
|
42
42
|
export const DIR_ENTRY_SIZE = 128;
|
|
43
43
|
export const MAX_NAME_CHARS = 31;
|
|
44
44
|
export function sameEntryName(a, b) {
|
|
45
|
-
return a
|
|
45
|
+
return entryNameKey(a) === entryNameKey(b);
|
|
46
|
+
}
|
|
47
|
+
export function entryNameKey(name) {
|
|
48
|
+
return `${name.length}:${name.toUpperCase()}`;
|
|
46
49
|
}
|
package/dist/vba/cfb-writer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { quoted } from '../errors.js';
|
|
2
|
-
import { CFB_SIGNATURE, DIR_ENTRY_FIELD, DIR_ENTRY_SIZE, ENDOFCHAIN, FATSECT, FREESECT, HEADER_DIFAT_SLOTS, HEADER_FIELD, MAX_NAME_CHARS, MINI_SECTOR_SHIFT, MINI_STREAM_CUTOFF, NOSTREAM, TYPE_ROOT, TYPE_STORAGE, TYPE_STREAM, } from './cfb-format.js';
|
|
2
|
+
import { CFB_SIGNATURE, DIR_ENTRY_FIELD, DIR_ENTRY_SIZE, ENDOFCHAIN, entryNameKey, FATSECT, FREESECT, HEADER_DIFAT_SLOTS, HEADER_FIELD, MAX_NAME_CHARS, MINI_SECTOR_SHIFT, MINI_STREAM_CUTOFF, NOSTREAM, TYPE_ROOT, TYPE_STORAGE, TYPE_STREAM, } from './cfb-format.js';
|
|
3
3
|
import { VbaAuthorError } from './errors.js';
|
|
4
4
|
export function isStream(node) {
|
|
5
5
|
return 'data' in node;
|
|
@@ -150,10 +150,11 @@ function validateSiblingNames(storageName, siblings) {
|
|
|
150
150
|
if (node.name.length > MAX_NAME_CHARS) {
|
|
151
151
|
throw new VbaAuthorError(`entry name ${quoted(node.name)} exceeds the ${MAX_NAME_CHARS}-character CFB limit`);
|
|
152
152
|
}
|
|
153
|
-
|
|
153
|
+
const key = entryNameKey(node.name);
|
|
154
|
+
if (seen.has(key)) {
|
|
154
155
|
throw new VbaAuthorError(`duplicate entry name ${quoted(node.name)} under storage ${quoted(storageName)}`);
|
|
155
156
|
}
|
|
156
|
-
seen.add(
|
|
157
|
+
seen.add(key);
|
|
157
158
|
if (!isStream(node))
|
|
158
159
|
validateSiblingNames(node.name, node.children);
|
|
159
160
|
}
|