Skip to content

Commit 09ebf1b

Browse files
committed
Remove ignored UTF8 setting in diagMode()
Unreleased functions Diagnose() and DiagnoseFirst() added in v2.5.0-beta3 were ignoring the setting of DecOptions.UTF8 = DecodeInvalidUTF8 in the underlying decoder. Given this, removing the ignored code is enough to make the new diagnostic functions match the default behavior of CBOR decoder which is to reject invalid UTF-8 in CBOR text strings. For now, it doesn't make sense to print invalid UTF-8 text because the Diagnostic Notation described by RFC 8949 and the Extended Diagnostic Notation in Appendix G of RFC 8610 don't specify how to represent invalid UTF-8.
1 parent 8864562 commit 09ebf1b

File tree

2 files changed

+0
-18
lines changed

2 files changed

+0
-18
lines changed

diagnose.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,6 @@ func (opts DiagOptions) diagMode() (*diagMode, error) {
111111
MaxNestedLevels: opts.MaxNestedLevels,
112112
MaxArrayElements: opts.MaxArrayElements,
113113
MaxMapPairs: opts.MaxMapPairs,
114-
// loosest decode options for diagnostic purpose.
115-
UTF8: UTF8DecodeInvalid,
116114
}.decMode()
117115
if err != nil {
118116
return nil, err

diagnose_test.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -583,14 +583,6 @@ func TestDiagnoseTextString(t *testing.T) {
583583
ByteStringText: true,
584584
},
585585
},
586-
// {
587-
// "invalid UTF-8 text in text string",
588-
// hexDecode("6d68656c6c6fffeee4bda0e5a5bd"),
589-
// `"hello\u00ff\u00ee\u4f60\u597d"`,
590-
// &DiagOptions{
591-
// ByteStringText: true,
592-
// },
593-
// },
594586
{
595587
"valid grapheme cluster text in byte string",
596588
hexDecode("583448656c6c6f2c2027e29da4efb88fe2808df09f94a5270ae4bda0e5a5bdefbc8c22f09fa791e2808df09fa49de2808df09fa79122"),
@@ -615,14 +607,6 @@ func TestDiagnoseTextString(t *testing.T) {
615607
ByteStringText: true,
616608
},
617609
},
618-
// {
619-
// "invalid grapheme cluster text in text string",
620-
// hexDecode("783448656c6c6feeff27e29da4efb88fe2808df09f94a5270de4bda0e5a5bdefbc8c22f09fa791e2808df09fa49de2808df09fa79122"),
621-
// `"Hello\u00ee\u00ff'\u2764\ufe0f\u200d\ud83d\udd25'\r\u4f60\u597d\uff0c\"\ud83e\uddd1\u200d\ud83e\udd1d\u200d\ud83e\uddd1\""`,
622-
// &DiagOptions{
623-
// ByteStringText: true,
624-
// },
625-
// },
626610
{
627611
"indefinite length text string with no chunks",
628612
hexDecode("7fff"),

0 commit comments

Comments
 (0)