Fix overlapping entity masking (#33)
authorStefan Gasser <redacted>
Fri, 16 Jan 2026 14:09:32 +0000 (15:09 +0100)
committerStefan Gasser <redacted>
Fri, 16 Jan 2026 15:40:28 +0000 (16:40 +0100)
commitc8cc3cfc3449336bf8005b1445a9ed1a677ddcee
tree5ddc921af826954d993edc58c4556f1b3e5c1534
parentd239944614c8be1153cdb8ccfc2afb2b48a94f30
Fix overlapping entity masking (#33)

Presidio can return overlapping PII detections (e.g., both "Eric" and
"Eric's" as separate PERSON entities). When both were masked, the string
positions became invalid, corrupting the output.

Added removeOverlappingEntities() to filter overlaps before masking:
- Sort by start position (longer first if same start)
- Keep only non-overlapping entities
src/secrets/redact.ts
src/services/masking.test.ts
src/services/masking.ts
src/utils/entities.test.ts [new file with mode: 0644]
src/utils/entities.ts [new file with mode: 0644]
git clone https://git.99rst.org/PROJECT