Repository navigation
checksum: unescape names only on lines starting with a backslash - #16167
Conversation
Merging this PR will not alter performance1 warning, 1 note
Comparing Footnotes
|
| 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"\\"); |
There was a problem hiding this comment.
could use strip_escape_marker here too, no?
There was a problem hiding this comment.
Yes, it fits: switched it to strip_escape_marker in 281747d, same behaviour, the tests still pass.
|
Thanks for your PR |
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, somd5sum -crejected 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 throughstrip_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). Alltest_md5sumandtest_cksumtests and the uucore checksum unit tests pass, clippy and fmt are clean.Found with behave.