Skip to content

Commit 0fea54f

Browse files
sourcefrogvrmiguel
authored andcommitted
fix: Binary files line with crlf
1 parent 4fc2075 commit 0fea54f

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ fn binary_files_differ(input: Input<'_>) -> IResult<Input<'_>, Patch> {
126126
"Binary file line",
127127
delimited(
128128
tag("Binary files "),
129-
map_opt(take_until(" differ\n"), |names: Input<'_>| {
129+
map_opt(take_until(" differ"), |names: Input<'_>| {
130130
names.split_once(" and ")
131131
}),
132132
pair(tag(" differ"), line_ending),

tests/parse_patch.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,18 @@ fn test_parse_triple_plus_minus_hack() {
286286
assert_eq!(format!("{}\n", patch), sample);
287287
}
288288

289+
#[test]
290+
fn binary_diff_with_crlf() {
291+
let sample = "Binary files old.bin and new.bin differ\r\n";
292+
293+
let patch = Patch::from_single(sample).unwrap();
294+
assert_eq!(patch.old.path, "old.bin");
295+
assert_eq!(patch.old.meta, None);
296+
assert_eq!(patch.new.path, "new.bin");
297+
assert_eq!(patch.new.meta, None);
298+
assert_eq!(patch.hunks, []);
299+
}
300+
289301
#[test]
290302
fn binary_diff_with_spaces_in_name() {
291303
let sample = "Binary files an old binary and a new binary differ\n";

0 commit comments

Comments
 (0)