fix snbt decoding bug found in #121
This commit is contained in:
@ -247,7 +247,7 @@ func writeListOrArray(e *Encoder, d *decodeState) (tagType byte, err error) {
|
|||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if d.opcode != scanListValue { // TAG_List<TAG_String>
|
if d.opcode != scanListValue && d.opcode != scanEndValue { // TAG_List<TAG_String>
|
||||||
panic(phasePanicMsg)
|
panic(phasePanicMsg)
|
||||||
}
|
}
|
||||||
var tagType byte
|
var tagType byte
|
||||||
|
@ -48,6 +48,9 @@ var testCases = []testCase{
|
|||||||
{`{d:[]}`, TagCompound, []byte{10, 0, 0, 9, 0, 1, 'd', 0, 0, 0, 0, 0, 0}},
|
{`{d:[]}`, TagCompound, []byte{10, 0, 0, 9, 0, 1, 'd', 0, 0, 0, 0, 0, 0}},
|
||||||
{`{e:[]}`, TagCompound, []byte{10, 0, 0, 9, 0, 1, 'e', 0, 0, 0, 0, 0, 0}},
|
{`{e:[]}`, TagCompound, []byte{10, 0, 0, 9, 0, 1, 'e', 0, 0, 0, 0, 0, 0}},
|
||||||
{`{f:[], g:[]}`, TagCompound, []byte{10, 0, 0, 9, 0, 1, 'f', 0, 0, 0, 0, 0, 9, 0, 1, 'g', 0, 0, 0, 0, 0, 0}},
|
{`{f:[], g:[]}`, TagCompound, []byte{10, 0, 0, 9, 0, 1, 'f', 0, 0, 0, 0, 0, 9, 0, 1, 'g', 0, 0, 0, 0, 0, 0}},
|
||||||
|
|
||||||
|
// issue#121
|
||||||
|
{`{a:[b],c:0B}`, TagCompound, []byte{10, 0, 0, 9, 0, 1, 'a', 8, 0, 0, 0, 1, 0, 1, 'b', 1, 0, 1, 'c', 0, 0}},
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestStringifiedMessage_TagType(t *testing.T) {
|
func TestStringifiedMessage_TagType(t *testing.T) {
|
||||||
|
@ -9,7 +9,7 @@ func TestSNBT_checkScanCode(t *testing.T) {
|
|||||||
//t.SkipNow()
|
//t.SkipNow()
|
||||||
var s scanner
|
var s scanner
|
||||||
s.reset()
|
s.reset()
|
||||||
for _, c := range []byte(`[I;123,345], `) {
|
for _, c := range []byte(`{b:[vanilla],c:0D}`) {
|
||||||
t.Logf("[%c] - %d", c, s.step(&s, c))
|
t.Logf("[%c] - %d", c, s.step(&s, c))
|
||||||
}
|
}
|
||||||
t.Logf("[%c] - %d", ' ', s.eof())
|
t.Logf("[%c] - %d", ' ', s.eof())
|
||||||
|
Reference in New Issue
Block a user