From 85566c372e9a7c85fce98bde46f942e58b223126 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sun, 23 Jan 2022 13:01:48 -0600 Subject: [PATCH] test: tests for magnet links with bad/junk values (#2483) Co-authored-by: Srinidhi Kaushik --- tests/libtransmission/magnet-metainfo-test.cc | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tests/libtransmission/magnet-metainfo-test.cc b/tests/libtransmission/magnet-metainfo-test.cc index 0d5c589b1..e8d0e7175 100644 --- a/tests/libtransmission/magnet-metainfo-test.cc +++ b/tests/libtransmission/magnet-metainfo-test.cc @@ -30,6 +30,27 @@ TEST(MagnetMetainfo, magnetParse) "&tr=http%3A%2F%2Ftracker.opentracker.org%2Fannounce" "&ws=http%3A%2F%2Fserver.webseed.org%2Fpath%2Fto%2Ffile"sv; + auto constexpr UriHexWithEmptyValue = + "magnet:?xt=urn:btih:" + "d2354010a3ca4ade5b7427bb093a62a3899ff381" + "&empty" + "&dn=Display%20Name" + "&tr=http%3A%2F%2Ftracker.openbittorrent.com%2Fannounce" + "&tr=http%3A%2F%2Ftracker.opentracker.org%2Fannounce" + "&ws=http%3A%2F%2Fserver.webseed.org%2Fpath%2Fto%2Ffile"sv; + + auto constexpr UriHexWithJunkValues = + "magnet:?xt=urn:btih:" + "d2354010a3ca4ade5b7427bb093a62a3899ff381" + "&empty" + "&empty_again" + "&dn=Display%20Name" + "&tr=http%3A%2F%2Ftracker.openbittorrent.com%2Fannounce" + "&empty_again" + "&=" + "&ws=http%3A%2F%2Fserver.webseed.org%2Fpath%2Fto%2Ffile" + "&tr=http%3A%2F%2Ftracker.opentracker.org%2Fannounce"sv; + auto constexpr UriBase32 = "magnet:?xt=urn:btih:" "2I2UAEFDZJFN4W3UE65QSOTCUOEZ744B" @@ -38,7 +59,7 @@ TEST(MagnetMetainfo, magnetParse) "&ws=http%3A%2F%2Fserver.webseed.org%2Fpath%2Fto%2Ffile" "&tr=http%3A%2F%2Ftracker.opentracker.org%2Fannounce"sv; - for (auto const& uri : { UriHex, UriBase32 }) + for (auto const& uri : { UriHex, UriHexWithEmptyValue, UriHexWithJunkValues, UriBase32 }) { auto mm = tr_magnet_metainfo{};