From 63027e1d5aec49f80adf1d9cb533e2718285dea5 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sun, 29 Nov 2009 08:05:47 +0000 Subject: [PATCH] (trunk libT) resolve "noslashes" vs "keep_slashes" variable name inconsistency between the declaration and the definition of tr_http_escape() --- libtransmission/announcer.c | 2 +- libtransmission/web.c | 12 +++++++++--- libtransmission/web.h | 2 +- libtransmission/webseed.c | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/libtransmission/announcer.c b/libtransmission/announcer.c index 575a4390d..fa7806016 100644 --- a/libtransmission/announcer.c +++ b/libtransmission/announcer.c @@ -703,7 +703,7 @@ createAnnounceURL( const tr_announcer * announcer, char ipv6_readable[INET6_ADDRSTRLEN]; inet_ntop( AF_INET6, ipv6, ipv6_readable, INET6_ADDRSTRLEN ); evbuffer_add_printf( buf, "&ipv6="); - tr_http_escape( buf, ipv6_readable, strlen(ipv6_readable), 0 ); + tr_http_escape( buf, ipv6_readable, strlen(ipv6_readable), TRUE ); } ret = tr_strndup( EVBUFFER_DATA( buf ), EVBUFFER_LENGTH( buf ) ); diff --git a/libtransmission/web.c b/libtransmission/web.c index 4817a03e8..b3e84b484 100644 --- a/libtransmission/web.c +++ b/libtransmission/web.c @@ -649,12 +649,18 @@ tr_webGetResponseStr( long code ) } /* escapes a string to be URI-legal as per RFC 2396. - like curl_escape() but can optionally avoid munging slashes. */ + like curl_escape() but can optionally avoid escaping slashes. */ void -tr_http_escape( struct evbuffer *out, const char *str, int len, int keep_slashes ) +tr_http_escape( struct evbuffer * out, + const char * str, + int len, + tr_bool escape_slashes ) { int i; + if( ( len < 0 ) && ( str != NULL ) ) + len = strlen( str ); + for( i = 0; i < len; i++ ) { switch( str[i] ) { case ',': case '-': case '.': @@ -673,7 +679,7 @@ tr_http_escape( struct evbuffer *out, const char *str, int len, int keep_slashes evbuffer_add( out, &str[i], 1 ); break; case '/': - if(keep_slashes) { + if(!escape_slashes) { evbuffer_add( out, &str[i], 1 ); break; } diff --git a/libtransmission/web.h b/libtransmission/web.h index 0d385fe95..f1e4b8eac 100644 --- a/libtransmission/web.h +++ b/libtransmission/web.h @@ -38,7 +38,7 @@ void tr_webRun( tr_session * session, struct evbuffer; -void tr_http_escape( struct evbuffer *out, const char *str, int len, int noslashes ); +void tr_http_escape( struct evbuffer *out, const char *str, int len, tr_bool escape_slashes ); char* tr_http_unescape( const char * str, int len ); diff --git a/libtransmission/webseed.c b/libtransmission/webseed.c index 9232f40e5..2d5f1cf09 100644 --- a/libtransmission/webseed.c +++ b/libtransmission/webseed.c @@ -109,7 +109,7 @@ makeURL( tr_webseed * w, /* if url ends with a '/', add the torrent name */ if( url[url_len - 1] == '/' && file->name ) - tr_http_escape( out, file->name, strlen(file->name), 1 ); + tr_http_escape( out, file->name, strlen(file->name), FALSE ); ret = tr_strndup( EVBUFFER_DATA( out ), EVBUFFER_LENGTH( out ) ); evbuffer_free( out );