From 9414a7fd024dba6c70c3c204e7a98dd807572f4a Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Mon, 1 Dec 2025 11:20:16 -0800 Subject: Allow octal and hex escapes to take fewer digits --- ccl_test.go | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'ccl_test.go') diff --git a/ccl_test.go b/ccl_test.go index 8aaca98..42c71a9 100644 --- a/ccl_test.go +++ b/ccl_test.go @@ -259,6 +259,26 @@ can just span multiple lines"`, desc: "StringOctal", msg: `string: '\033'`, want: message{String: "\033"}, + }, { + desc: "StringOctalOne", + msg: `string:'\0asdf'`, + want: message{String: "\x00asdf"}, + }, { + desc: "StringOctalTwo", + msg: `string:'\33['`, + want: message{String: "\033["}, + }, { + desc: "StringOctalFour", + msg: `string:'\1234'`, + want: message{String: "\1234"}, + }, { + desc: "StringHexOne", + msg: `string:'\xfhello'`, + want: message{String: "\x0fhello"}, + }, { + desc: "StringHexThree", + msg: `string:'\x0ff'`, + want: message{String: "\x0ff"}, }, { desc: "StringStripCarriageReturn", msg: "string:'a\r\nb'", @@ -403,9 +423,6 @@ func TestUnmarshal_Invalid(t *testing.T) { }, { desc: "StringBadReturnEscape", msg: "string:'\\\r'", - }, { - desc: "StringShortHex", - msg: `string:"\x1"`, }, { desc: "StringBadHex", msg: `string:"\xgg"`, -- cgit v1.3.1