1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-26 01:27:28 +00:00

(trunk libT) resolve "noslashes" vs "keep_slashes" variable name inconsistency between the declaration and the definition of tr_http_escape()

This commit is contained in:
Charles Kerr 2009-11-29 08:05:47 +00:00
parent c841adaf56
commit 63027e1d5a
4 changed files with 12 additions and 6 deletions

View file

@ -703,7 +703,7 @@ createAnnounceURL( const tr_announcer * announcer,
char ipv6_readable[INET6_ADDRSTRLEN]; char ipv6_readable[INET6_ADDRSTRLEN];
inet_ntop( AF_INET6, ipv6, ipv6_readable, INET6_ADDRSTRLEN ); inet_ntop( AF_INET6, ipv6, ipv6_readable, INET6_ADDRSTRLEN );
evbuffer_add_printf( buf, "&ipv6="); 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 ) ); ret = tr_strndup( EVBUFFER_DATA( buf ), EVBUFFER_LENGTH( buf ) );

View file

@ -649,12 +649,18 @@ tr_webGetResponseStr( long code )
} }
/* escapes a string to be URI-legal as per RFC 2396. /* 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 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; int i;
if( ( len < 0 ) && ( str != NULL ) )
len = strlen( str );
for( i = 0; i < len; i++ ) { for( i = 0; i < len; i++ ) {
switch( str[i] ) { switch( str[i] ) {
case ',': case '-': case '.': 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 ); evbuffer_add( out, &str[i], 1 );
break; break;
case '/': case '/':
if(keep_slashes) { if(!escape_slashes) {
evbuffer_add( out, &str[i], 1 ); evbuffer_add( out, &str[i], 1 );
break; break;
} }

View file

@ -38,7 +38,7 @@ void tr_webRun( tr_session * session,
struct evbuffer; 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 ); char* tr_http_unescape( const char * str, int len );

View file

@ -109,7 +109,7 @@ makeURL( tr_webseed * w,
/* if url ends with a '/', add the torrent name */ /* if url ends with a '/', add the torrent name */
if( url[url_len - 1] == '/' && file->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 ) ); ret = tr_strndup( EVBUFFER_DATA( out ), EVBUFFER_LENGTH( out ) );
evbuffer_free( out ); evbuffer_free( out );