Allow empty dist name in bencode which is needed for hybrid torrent

This commit is contained in:
Tatsuhiro Tsujikawa
2022-04-08 22:48:00 +09:00
parent 37a7419fed
commit ba36a38a6c
7 changed files with 41 additions and 5 deletions

View File

@@ -208,6 +208,16 @@ void ValueBaseBencodeParserTest::testParseUpdate()
// Get trailing garbage position
CPPUNIT_ASSERT_EQUAL((ssize_t)7, error);
}
{
// dict, empty member name
std::string src = "d0:i123ee";
std::shared_ptr<ValueBase> d =
parser.parseFinal(src.c_str(), src.size(), error);
Dict* dict = downcast<Dict>(d);
CPPUNIT_ASSERT(dict);
CPPUNIT_ASSERT(dict->get(""));
CPPUNIT_ASSERT_EQUAL((int64_t)123, downcast<Integer>(dict->get(""))->i());
}
}
} // namespace aria2