TSV output is unescaped: paths with tabs or newlines corrupt the report #7
Reference in New Issue
Block a user
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?
reportwrites paths raw (report.go:79,fmt.Fprintf(out, "%s\t%s\t%d\n", ...)) andtreesdoes the same (trees.go:59). The database layer deliberately supports paths containing tabs and newlines —db_test.go:138-141round-trips/a/tab\tnew\nlinewith the comment "Paths may contain tabs and newlines" — and README §Database states paths are stored as raw bytes because Unix paths are not guaranteed UTF-8.So a single file whose name contains a tab or a newline silently corrupts the machine-readable output that is this tool's entire product. README §Report output format and §Trees output format say nothing about escaping.
Second, related defect in the same output path:
trees.go:96-101splits paths on/, which yields a leading empty component, and because the node's parent is the synthetic super-root itspathis set to the empty string rather than/.suppressed(trees.go:221-223) never suppresses a group whose parent is the super-root, so such a group is always reported — printing an emptyfirstordupefield. Unreachable with a single scanned root today, but it is the same class of malformed-TSV bug and the node path is simply wrong on inspection.Definition of done
\t,\n,\rand\\, applied to path columns only, and applied to the per-path warnings on stderr as well so the two agree.reportandtreesimplement it./so no empty field can ever be emitted.reportandtrees; a hierarchy built from/fasserts the root node's path is/.make checkgreen.