Fix #247
This commit is contained in:
parent
e9386d1016
commit
d7225aed03
|
@ -495,8 +495,9 @@ func (d *Decoder) parseValue(v reflect.Value) (bool, error) {
|
||||||
return true, nil
|
return true, nil
|
||||||
default:
|
default:
|
||||||
if b >= '0' && b <= '9' {
|
if b >= '0' && b <= '9' {
|
||||||
// string
|
// It's a string.
|
||||||
// append first digit of the length to the buffer
|
d.buf.Reset()
|
||||||
|
// Write the first digit of the length to the buffer.
|
||||||
d.buf.WriteByte(b)
|
d.buf.WriteByte(b)
|
||||||
return true, d.parseString(v)
|
return true, d.parseString(v)
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,3 +128,12 @@ func TestMetainfoWithStringURLList(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Len(t, mi.UrlList, 1)
|
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))
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue