fix(recency): find -printf uses \n record separator — breaks on filenames containing newlines #86
Loading…
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?
Problem
find_recent_filesuses a newline-separated record format and splits on newline:luminos_lib/recency.py:20:luminos_lib/recency.py:34:A filename containing a literal
\n(valid on POSIX filesystems) produces a record that looks like two records when split. The second half then fails theparts = line.split("\t", 1)/float(parts[0])checks and is silently dropped. The first half has the timestamp but a truncated path — so it's either silently dropped (if the truncated path failsfloat) or surfaces a wrong path in the "recent files" list.Severity
Low: newline-in-filename is rare in practice. But the fix is small and the current silent-corruption mode is worse than no result.
Fix
Use NUL as the record separator:
And split on
"\x00":Same pattern works in
classify_filesif this ever gets ported to usefind, and in any future helper that shells out tofind -print.Acceptance
recency.pyuses NUL separatortests/test_recency.pygets a case for newline-in-filename (mocked subprocess output)