diff --git a/src/history/file.rs b/src/history/file.rs index 40f326080..3240dd3c5 100644 --- a/src/history/file.rs +++ b/src/history/file.rs @@ -358,9 +358,7 @@ fn decode_item_fish_2_0(mut data: &[u8]) -> Option { let (advance, line) = read_line(data); let line = trim_start(line); // Check this early *before* anything else. - if !line.starts_with(b"- cmd") { - return None; - } + assert!(line.starts_with(b"- cmd")); let (_key, value) = extract_prefix_and_unescape_yaml(line)?; @@ -496,6 +494,15 @@ fn offset_of_next_item_fish_2_0( continue; } + if !line.starts_with(b"- cmd") { + FLOG!( + history, + "ignoring corrupted history entry around offset", + *cursor + ); + continue; + } + // At this point, we know `line` is at the beginning of an item. But maybe we want to // skip this item because of timestamps. A `None` cutoff means we don't care; if we do care, // then try parsing out a timestamp.