Skip to content

checksum: unescape names only on lines starting with a backslash - #16167

Merged
sylvestre merged 2 commits into
uutils:mainfrom
emirmrkaljevic:checksum-escaped-lines
Nov 5, 2026
Merged

sylvestre merged 2 commits into
uutils:mainfrom
emirmrkaljevic:checksum-escaped-lines

Conversation

@emirmrkaljevic

Copy link
Copy Markdown
Contributor

Fixes #16166

md5sum marks a line with an escaped file name by starting it with a \. The tagged parser skipped that marker, but the untagged and single-space parsers did not, so md5sum -c rejected its own output for names containing a backslash or a newline. At the same time, every name was unescaped, even on lines without the marker.

This records whether the line started with a \ (LineInfo::escaped, set by all three parsers through strip_escape_marker) and only unescapes the name in that case.

Test: test_check_escaped_file_names (escaped untagged and binary-mode lines, md5sum's own output, and a name that must not be unescaped). All test_md5sum and test_cksum tests and the uucore checksum unit tests pass, clippy and fmt are clean.

Found with behave.

@codspeed

codspeed Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning, 1 note

⚠️ 124 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

ℹ️ 1 benchmark has no flamegraph

The flamegraph wasn't generated: most of the time was spent in runtime internals, which would leave nothing useful to analyze.

See affected benchmarks

✅ 401 untouched benchmarks
⏩ 70 skipped benchmarks1


Comparing emirmrkaljevic:checksum-escaped-lines (281747d) with main (88707ee)2

Open in CodSpeed

Footnotes

  1. 70 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on main (c9c790b) during the generation of this report, so 88707ee was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

let trimmed = line.trim_blanks_start();
let algo_start = usize::from(trimmed.starts_with(b"\\"));
let rest = &trimmed[algo_start..];
let escaped = trimmed.starts_with(b"\\");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could use strip_escape_marker here too, no?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it fits: switched it to strip_escape_marker in 281747d, same behaviour, the tests still pass.

@sylvestre
sylvestre merged commit 7c1ddec into uutils:main Nov 5, 2026
228 of 229 checks passed
@sylvestre

Copy link
Copy Markdown
Contributor

Thanks for your PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

md5sum -c: escaped file names (line starting with \) are rejected, and names are unescaped without it

2 participants