Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/src/gen5_records.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

import 'dart:typed_data';

import 'constants.dart' show PacketType;
import 'records.dart' show kMinRrMs, kMaxRrMs;

ByteData _view(Uint8List b) =>
Expand Down Expand Up @@ -1869,6 +1870,8 @@ const List<Gen5RecordDecoder> kGen5HistoricalDecoders = [
/// those, exactly like `parseR24`'s null contract.
Gen5HistoricalRecord? parseGen5Historical(Uint8List inner) {
if (inner.length < 11) return null; // shorter than the shared header itself
// inner[1] is the sequence byte on a control frame; same trap parseR24 gates.
if (inner[0] != PacketType.historicalData) return null;

if (_v21Decoder.matches(inner)) return _v21Decoder.decode(inner);

Expand Down
13 changes: 13 additions & 0 deletions test/gen5_historical_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -931,4 +931,17 @@ void main() {
});
}
});

test('parseGen5Historical ignores non-record packet types', () {
for (final t in [
PacketType.consoleLogs,
PacketType.commandResponse,
PacketType.event,
]) {
final inner = Uint8List(112);
inner[0] = t;
inner[1] = 18; // seq byte that looks like a v18 version
expect(parseGen5Historical(inner), isNull, reason: 'type 0x${t.toRadixString(16)}');
}
});
}
Loading