return true, nil
default:
if b >= '0' && b <= '9' {
- // string
- // append first digit of the length to the buffer
+ // It's a string.
+ d.buf.Reset()
+ // Write the first digit of the length to the buffer.
d.buf.WriteByte(b)
return true, d.parseString(v)
}
require.NoError(t, err)
assert.Len(t, mi.UrlList, 1)
}
+
+// https://github.com/anacrolix/torrent/issues/247
+//
+// The decoder buffer wasn't cleared before starting the next dict item after
+// a syntax error on a field with the ignore_unmarshal_type_error tag.
+func TestStringCreationDate(t *testing.T) {
+ var mi MetaInfo
+ assert.NoError(t, bencode.Unmarshal([]byte("d13:creation date23:29.03.2018 22:18:14 UTC4:infodee"), &mi))
+}