@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.
@@ -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;
@@ -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.length === b.length && a.toUpperCase() === b.toUpperCase();
45
+ return entryNameKey(a) === entryNameKey(b);
46
+ }
47
+ export function entryNameKey(name) {
48
+ return `${name.length}:${name.toUpperCase()}`;
46
49
  }
@@ -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
- if (seen.has(node.name)) {
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(node.name);
157
+ seen.add(key);
157
158
  if (!isStream(node))
158
159
  validateSiblingNames(node.name, node.children);
159
160
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shbernal/ts-xlsx",
3
- "version": "3.2.2-next.25.g7699212",
3
+ "version": "3.2.2-next.26.gf63f249",
4
4
  "description": "A TypeScript-first library for reading and writing xlsx (OOXML) spreadsheets.",
5
5
  "keywords": [
6
6
  "csv",