(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:
Jordan Lee
2011-04-05 22:21:18 +00:00
parent 4694f95594
commit f37da42a8c
2 changed files with 14 additions and 2 deletions

View File

@@ -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;
}