(trunk libT) fix ABR error when parsing a URL with no path and no trailing slash after the host. Error reported by livings124
This commit is contained in:
parent
4694f95594
commit
f37da42a8c
|
@ -385,6 +385,16 @@ test_url( void )
|
|||
char * str;
|
||||
const char * url;
|
||||
|
||||
url = "http://1";
|
||||
check( !tr_urlParse( url, -1, &scheme, &host, &port, &path ) );
|
||||
check( !strcmp( scheme, "http" ) )
|
||||
check( !strcmp( host, "1" ) )
|
||||
check( !strcmp( path, "/" ) )
|
||||
check( port == 80 )
|
||||
tr_free( scheme );
|
||||
tr_free( path );
|
||||
tr_free( host );
|
||||
|
||||
url = "http://www.some-tracker.org/some/path";
|
||||
check( !tr_urlParse( url, -1, &scheme, &host, &port, &path ) )
|
||||
check( !strcmp( scheme, "http" ) )
|
||||
|
|
|
@ -1030,7 +1030,8 @@ tr_urlParse( const char * url_in,
|
|||
host = pch;
|
||||
host_len = n;
|
||||
pch += n;
|
||||
*pch++ = '\0';
|
||||
if( pch && *pch )
|
||||
*pch++ = '\0';
|
||||
/*fprintf( stderr, "host is [%s]... what's left is [%s]\n", host, pch );*/
|
||||
if( havePort )
|
||||
{
|
||||
|
@ -1061,7 +1062,8 @@ tr_urlParse( const char * url_in,
|
|||
|
||||
if( setme_host ){ ( (char*)host )[-3] = ':'; *setme_host =
|
||||
tr_strndup( host, host_len ); }
|
||||
if( setme_path ){ if( path[0] == '/' ) *setme_path = tr_strdup( path );
|
||||
if( setme_path ){ if( !*path ) *setme_path = tr_strdup( "/" );
|
||||
else if( path[0] == '/' ) *setme_path = tr_strdup( path );
|
||||
else { ( (char*)path )[-1] = '/'; *setme_path = tr_strdup( path - 1 ); } }
|
||||
if( setme_port ) *setme_port = port;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue