From 9666676766bf21364f4fc4d0d1d336e72f2a91b4 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Tue, 6 Oct 2026 12:57:23 -0400 Subject: refactor: split casino.go, dedup helpers, remove audit docs --- internal/net/iac_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'internal/net/iac_test.go') diff --git a/internal/net/iac_test.go b/internal/net/iac_test.go index 71570db..6f91f19 100644 --- a/internal/net/iac_test.go +++ b/internal/net/iac_test.go @@ -15,3 +15,18 @@ func TestStripIACDropsTruncatedSequence(t *testing.T) { t.Fatalf("stripIAC(subnegotiation) = %q, want xy", got) } } + +func TestStripIACPreservesInputAfterTwoByteCommand(t *testing.T) { + // A 2-byte command (NOP) in the middle must not eat the following byte. + if got := stripIAC("a" + string([]byte{iac, 0xf1}) + "b"); got != "ab" { + t.Fatalf("stripIAC(mid two-byte command) = %q, want %q", got, "ab") + } + // A 3-byte negotiation command consumes its option byte. + if got := stripIAC("a" + string([]byte{iac, will, echo}) + "b"); got != "ab" { + t.Fatalf("stripIAC(three-byte command) = %q, want %q", got, "ab") + } + // IAC IAC is an escaped literal 0xFF, not a command. + if got := stripIAC("a" + string([]byte{iac, iac}) + "b"); got != "a"+string([]byte{iac})+"b" { + t.Fatalf("stripIAC(escaped IAC) = %q, want literal 0xFF", got) + } +} -- cgit v1.2.3