$OpenBSD: patch-src_download_download_constructor_cc,v 1.3 2012/07/15 10:20:07 dcoppa Exp $

Fix: libtorrent rejects a torrent which has a valid announce but a
malformed announce-list (http://libtorrent.rakshasa.no/ticket/2505)

Spelling fixes

--- src/download/download_constructor.cc.orig	Tue Jun  7 12:52:57 2011
+++ src/download/download_constructor.cc	Fri Jul 13 12:46:49 2012
@@ -98,6 +98,15 @@ DownloadConstructor::initialize(Object& b) {
   parse_name(b.get_key("info"));
   parse_info(b.get_key("info"));
 
+  if (b.has_key_list("announce-list"))
+    if (b.get_key_list("announce-list").empty()) {
+      b.erase_key("announce-list");
+    } else {
+      Object::list_type & l = b.get_key_list("announce-list");
+      if (l.size() == 1 && !l.begin()->is_list()) {
+        b.erase_key("announce-list");  
+      }
+    }
   parse_tracker(b);
 }
 
@@ -344,7 +353,7 @@ DownloadConstructor::create_path(const Object::list_ty
     throw input_error("Bad torrent file, \"path\" has zero entries.");
 
   if (std::find_if(plist.begin(), plist.end(), std::ptr_fun(&DownloadConstructor::is_invalid_path_element)) != plist.end())
-    throw input_error("Bad torrent file, \"path\" has zero entries or a zero lenght entry.");
+    throw input_error("Bad torrent file, \"path\" has zero entries or a zero length entry.");
 
   Path p;
   p.set_encoding(enc);
