[mirrorbrain-commits] r7994 - /trunk/mod_mirrorbrain/mod_mirrorbrain.c

From: <poeml_at_mirrorbrain.org>
Date: Fri, 12 Mar 2010 21:20:38 -0000
Author: poeml
Date: Fri Mar 12 22:20:37 2010
New Revision: 7994

URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain?rev=7994&view=rev
Log:
mod_mirrorbrain:
- Magnet links include an HTTP URL to the file now
- The filename is now escaped in Magnet links

Modified:
    trunk/mod_mirrorbrain/mod_mirrorbrain.c

Modified: trunk/mod_mirrorbrain/mod_mirrorbrain.c
URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain/trunk/mod_mirrorbrain/mod_mirrorbrain.c?rev=7994&r1=7993&r2=7994&view=diff
==============================================================================
--- trunk/mod_mirrorbrain/mod_mirrorbrain.c (original)
+++ trunk/mod_mirrorbrain/mod_mirrorbrain.c Fri Mar 12 22:20:37 2010
_at_@ -1808,14 +1808,20 @@
         case METALINK:
         case MIRRORLIST:
             magnet = apr_psprintf(r->pool, "magnet:"
-                          "?xl=%s"          /* size */
-                          "&amp;dn=%s"          /* FIXME: the basename should be www-formencoded for
-                                                      spaces or funny characters */
+                          "?xl=%s"              /* size */
+                          "&amp;dn=%s"          /* file basename */
                           "&amp;xt=urn:sha1:%s"
                           "&amp;xt=urn:bith:%s" /* bittorrent information hash */
-                          "&amp;xt=urn:md5:%s", /* Gnutella */
-                       apr_off_t_toa(r->pool, r->finfo.size), basename,
-                       hashbag->sha1, hashbag->sha1, hashbag->md5); 
+                          "&amp;xt=urn:md5:%s"  /* Gnutella */
+                          "&amp;as=%s",         /* a HTTP link to the file */
+                       apr_off_t_toa(r->pool, r->finfo.size), 
+                       ap_escape_uri(r->pool, basename),
+                       hashbag->sha1, hashbag->sha1, hashbag->md5,
+                       apr_psprintf(r->pool, 
+                                    "http://%s%s", 
+                                    ap_escape_uri(r->pool, r->hostname), 
+                                    ap_escape_uri(r->pool, r->uri))
+                       ); 
 
             /* FIXME: including a tracker URL might be cool (&amp;tr=<tracker-url>) 
              * see http://mirrorbrain.org/issues/issue38 */




_______________________________________________
mirrorbrain-commits mailing list
Archive: http://mirrorbrain.org/archive/mirrorbrain-commits/

Note: To remove yourself from this list, send a mail with the content
 	unsubscribe
to the address mirrorbrain-commits-request_at_mirrorbrain.org
Received on Fri Mar 12 2010 - 21:20:40 GMT

This archive was generated by hypermail 2.3.0 : Mon Feb 20 2012 - 23:47:04 GMT