Define flat plus-tag encoding and collision rules #5
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: phg/fuse-mail-dir-by-tag#5
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Blocked by: #2, #4
Part of #1
Question
What canonical, reversible mapping turns each extracted Plus tag into exactly one flat Dovecot-visible Tag folder for a required per-instance mailbox hierarchy separator, while preserving intended spelling, preventing filesystem traversal and reserved-name problems, avoiding collisions, and defining behavior for empty, malformed, oversized, case-variant, Unicode, separator-containing, and otherwise unsafe tags?
Claimed by Codex agent
/rootfor a HITL decision session on 2026-07-23.Previous claim released after its session aborted. Claimed by Claude Code agent for a fresh HITL decision session on 2026-07-23.
Resolution
Use a two-stage, canonical, reversible mapping from each valid Plus tag to one flat Tag folder:
mailbox_list_layout = fsdirectory name.Logical encoding
Preserve ordinary printable Unicode, spaces, and punctuation. Percent-encode the original UTF-8 bytes as uppercase
%HHfor:%;/;Literal
%is always%25, making escape-looking source text unambiguous. Dovecot modified UTF-7 handles remaining Unicode in the physical name; for example, logicaläbecomes physical&AOQ-. Decode in reverse order: canonical modified UTF-7, then%HH, yielding the exact original UTF-8 Plus tag.Use no universal prefix. Prevent reserved-name conflicts by escaping the first UTF-8 byte when the otherwise encoded logical name begins with
.or~, equals.or.., case-insensitively equalsINBOX, or exactly equals lowercasecur,new, ortmp. Examples includecur→%63urand~team→%7Eteam.Identity and collisions
Plus-tag identity is exact validated UTF-8 bytes. Preserve case and Unicode sequence without case-folding or normalization:
Salesandsales, and NFC and decomposed spellings, remain distinct Tag folders. Deduplicate exact semantic suffixes only.The encoder emits uppercase escapes only. A decoder must decode and re-encode, accepting the name only when the result matches byte-for-byte. Reject lowercase escapes, unnecessary escapes, invalid hex, malformed/noncanonical modified UTF-7, invalid UTF-8, and unescaped reserved forms. This canonicality plus
%escaping and reversible modified UTF-7 prevents aliases and collisions.Invalid and oversized inputs
The recipient-parsing contract already rejects empty suffixes, malformed recipient occurrences, and invalid SMTPUTF8 before encoding. Continue processing valid sibling occurrences and other Plus tags.
After both encoding stages, reject only a Plus tag whose physical component exceeds the effective filesystem
NAME_MAXor Dovecot mailbox-name limit. Do not truncate it or replace it with a digest/catalog alias. Continue creating the message’s other valid Message projections. Emit a rate-limited diagnostic containing the failure class, encoded length, and a digest—not the recipient address or full Plus tag.Noncanonical names requested through the mounted namespace never create aliases: return the appropriate not-found or unsupported/read-only error and emit a rate-limited diagnostic.