Ignore:
Timestamp:
Feb 20, 2010, 3:57:05 PM (12 years ago)
Author:
charles
Message:

(trunk) #2938 "crash when adding a torrent by URL from an ftp source over RPC" -- fixed in trunk for 1.91

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/utils.c

    r10135 r10239  
    914914***/
    915915
    916 tr_bool
    917 tr_httpIsValidURL( const char * url )
     916static tr_bool
     917isValidURLChars( const char * url )
    918918{
    919919    const char * c;
     
    934934            return FALSE;
    935935
    936     return tr_httpParseURL( url, -1, NULL, NULL, NULL ) == 0;
    937 }
    938 
    939 tr_bool tr_addressIsIP( const char * address )
     936    return TRUE;
     937}
     938
     939/** @brief return TRUE if the url is a http or https url that Transmission understands */
     940tr_bool
     941tr_urlIsValidTracker( const char * url )
     942{
     943    tr_bool valid;
     944    char * scheme = NULL;
     945
     946    valid = isValidURLChars( url )
     947         && !tr_urlParse( url, -1, &scheme, NULL, NULL, NULL )
     948         && ( scheme != NULL )
     949         && ( !strcmp(scheme,"http") || !strcmp(scheme,"https") );
     950
     951    tr_free( scheme );
     952    return valid;
     953}
     954
     955/** @brief return TRUE if the url is a http or https or ftp or sftp url that Transmission understands */
     956tr_bool
     957tr_urlIsValid( const char * url )
     958{
     959    tr_bool valid;
     960    char * scheme = NULL;
     961
     962    valid = isValidURLChars( url )
     963         && !tr_urlParse( url, -1, &scheme, NULL, NULL, NULL )
     964         && ( scheme != NULL )
     965         && ( !strcmp(scheme,"http") || !strcmp(scheme,"https") || !strcmp(scheme,"ftp") || !strcmp(scheme,"sftp") );
     966
     967    tr_free( scheme );
     968    return valid;
     969}
     970
     971tr_bool
     972tr_addressIsIP( const char * address )
    940973{
    941974    tr_address tempAddr;
     
    944977
    945978int
    946 tr_httpParseURL( const char * url_in,
    947                  int          len,
    948                  char **      setme_host,
    949                  int *        setme_port,
    950                  char **      setme_path )
     979tr_urlParse( const char * url_in,
     980             int          len,
     981             char **      setme_protocol,
     982             char **      setme_host,
     983             int *        setme_port,
     984             char **      setme_path )
    951985{
    952986    int          err;
     
    9851019    }
    9861020
    987     err = !host || !path || !protocol
    988           || ( strcmp( protocol, "http" ) && strcmp( protocol, "https" ) );
     1021    err = !host || !path || !protocol;
    9891022
    9901023    if( !err && !port )
    9911024    {
     1025        if( !strcmp( protocol, "ftp" ) ) port = 21;
     1026        if( !strcmp( protocol, "sftp" ) ) port = 22;
    9921027        if( !strcmp( protocol, "http" ) ) port = 80;
    9931028        if( !strcmp( protocol, "https" ) ) port = 443;
     
    9961031    if( !err )
    9971032    {
     1033        if( setme_protocol ) *setme_protocol = tr_strdup( protocol );
     1034
    9981035        if( setme_host ){ ( (char*)host )[-3] = ':'; *setme_host =
    9991036                              tr_strdup( host ); }
Note: See TracChangeset for help on using the changeset viewer.