And, although rfc2396 said escaped letter can be upper character or lower character, but it's better to use lower case, er, as libtorrent, libtorrent-rasterbar, ktorrent, utorrent is in this way. Note: I use wireshark to get the announce url of utorrent, which is in close source.
--info_hash.escape.patch--
Code: Select all
diff -urp transmission-2.04/cli/cli.c transmission-2.04.patched/cli/cli.c
--- transmission-2.04/cli/cli.c 2010-08-07 11:35:34.000000000 +0800
+++ transmission-2.04.patched/cli/cli.c 2010-08-15 13:43:14.000000000 +0800
@@ -116,6 +116,10 @@ static int
is_rfc2396_alnum( char ch )
{
return ( '0' <= ch && ch <= '9' )
+ || ch == '.'
+ || ch == '-'
+ || ch == '_'
+ || ch == '~'
|| ( 'A' <= ch && ch <= 'Z' )
|| ( 'a' <= ch && ch <= 'z' );
}
@@ -131,7 +135,7 @@ escape( char * out,
if( is_rfc2396_alnum( *in ) )
*out++ = (char) *in++;
else
- out += tr_snprintf( out, 4, "%%%02X", (unsigned int)*in++ );
+ out += tr_snprintf( out, 4, "%%%02x", (unsigned int)*in++ );
*out = '\0';
}
diff -urp transmission-2.04/libtransmission/metainfo.c transmission-2.04.patched/libtransmission/metainfo.c
--- transmission-2.04/libtransmission/metainfo.c 2010-08-07 11:34:35.000000000 +0800
+++ transmission-2.04.patched/libtransmission/metainfo.c 2010-08-15 13:43:14.000000000 +0800
@@ -380,6 +380,10 @@ static int
is_rfc2396_alnum( char ch )
{
return ( '0' <= ch && ch <= '9' )
+ || ch == '.'
+ || ch == '-'
+ || ch == '_'
+ || ch == '~'
|| ( 'A' <= ch && ch <= 'Z' )
|| ( 'a' <= ch && ch <= 'z' );
}
@@ -393,7 +397,7 @@ escape( char * out, const uint8_t * in,
if( is_rfc2396_alnum( *in ) )
*out++ = (char) *in++;
else
- out += tr_snprintf( out, 4, "%%%02X", (unsigned int)*in++ );
+ out += tr_snprintf( out, 4, "%%%02x", (unsigned int)*in++ );
*out = '\0';
}