This commit is contained in:
Matt Joiner 2018-04-13 17:07:19 +10:00
parent e9386d1016
commit d7225aed03
2 changed files with 12 additions and 2 deletions

View File

@ -495,8 +495,9 @@ func (d *Decoder) parseValue(v reflect.Value) (bool, error) {
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)
}

View File

@ -128,3 +128,12 @@ func TestMetainfoWithStringURLList(t *testing.T) {
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))
}