Skip to content

[bug] archive-mail Step 2.1 find/while loop not null-safe to newlines in filenames (sister concern from #49) #57

Description

@kiki830621

Problem

From verification of #49:
while IFS= read -r mdfile not null-safe to filenames containing newlines. find outputs newline-separated paths; could split. Hygiene fix: find -print0 + read -d ''.」
— Source: idd-verify #49 (security review LOW #1)

archive-mail.md Step 2.1 sibling-archive dedup extension uses:

while IFS= read -r mdfile; do
    ...
done < <(find -P "$symlink_dir/" -maxdepth 2 -name "*.md" -type f 2>/dev/null)

If a *.md file has a newline character in its filename (unusual but legal on Unix), the path will split mid-loop, causing partial filename to be processed.

Type

bug (hygiene)

Realistic exposure

Low. Apple Mail subject lines typically don't have raw newlines (they're collapsed during header serialization). But:

  • Cross-platform paths from external archive sources might
  • Manual mv operations on archives with copy-paste-from-email could
  • POSIX allows newline in filenames

Priority

LOW — defensive hygiene fix.

Strategy sketch

Standard null-safe pattern:

while IFS= read -r -d '' mdfile; do
    ...
done < <(find -P "$symlink_dir/" -maxdepth 2 -name "*.md" -type f -print0 2>/dev/null)

Diff:

  • find adds -print0
  • while IFS= read -r becomes while IFS= read -r -d ''

Same change should apply to outer find (find -P "${output_dir}" -maxdepth 1 -type l -print0).

Priority again (with mitigation)

LOW (no realistic case for archive-mail's typical inputs) but trivial to fix and improves defensive posture.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions