aboutsummaryrefslogtreecommitdiff
path: root/internal/net/iac_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/net/iac_test.go')
-rw-r--r--internal/net/iac_test.go15
1 files changed, 15 insertions, 0 deletions
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)
+ }
+}