diff --git a/src/MonoTorrent.Tests/Common/TorrentTest.cs b/src/MonoTorrent.Tests/Common/TorrentTest.cs index 5f8590d39..b0511d21e 100644 --- a/src/MonoTorrent.Tests/Common/TorrentTest.cs +++ b/src/MonoTorrent.Tests/Common/TorrentTest.cs @@ -99,6 +99,8 @@ private BEncodedList CreateFiles () BEncodedList files = new BEncodedList (); BEncodedList path = new BEncodedList { + new BEncodedString (""), + new BEncodedString (""), new BEncodedString ("file1.txt") }; diff --git a/src/MonoTorrent/MonoTorrent/Torrent.cs b/src/MonoTorrent/MonoTorrent/Torrent.cs index aef1adefd..4426fff3d 100644 --- a/src/MonoTorrent/MonoTorrent/Torrent.cs +++ b/src/MonoTorrent/MonoTorrent/Torrent.cs @@ -210,8 +210,10 @@ IList LoadTorrentFiles (BEncodedList list) case ("path.utf-8"): foreach (BEncodedString str in ((BEncodedList) keypair.Value)) { - sb.Append (str.Text); - sb.Append (Path.DirectorySeparatorChar); + if (!BEncodedString.IsNullOrEmpty (str)) { + sb.Append (str.Text); + sb.Append (Path.DirectorySeparatorChar); + } } path = sb.ToString (0, sb.Length - 1); sb.Remove (0, sb.Length); @@ -220,8 +222,10 @@ IList LoadTorrentFiles (BEncodedList list) case ("path"): if (string.IsNullOrEmpty (path)) { foreach (BEncodedString str in ((BEncodedList) keypair.Value)) { - sb.Append (str.Text); - sb.Append (Path.DirectorySeparatorChar); + if (!BEncodedString.IsNullOrEmpty (str)) { + sb.Append (str.Text); + sb.Append (Path.DirectorySeparatorChar); + } } path = sb.ToString (0, sb.Length - 1); sb.Remove (0, sb.Length);