diff --git a/libtransmission/platform.c b/libtransmission/platform.c index 14b2a7bf4..cfcf7a049 100644 --- a/libtransmission/platform.c +++ b/libtransmission/platform.c @@ -610,13 +610,6 @@ tr_getClutchDir( const tr_session * session UNUSED ) #endif } - if( !*path ) - { - tr_strlcpy( path, "/dev/null", sizeof( path ) ); - tr_err( _( - "Couldn't find the web interface's files! To customize this, set the CLUTCH_HOME environmental variable to the folder where index.html is located." ) ); - } - s = tr_strdup( path ); } diff --git a/libtransmission/rpc-server.c b/libtransmission/rpc-server.c index 8aaad594d..99c69a61d 100644 --- a/libtransmission/rpc-server.c +++ b/libtransmission/rpc-server.c @@ -70,7 +70,7 @@ send_simple_response( struct evhttp_request * req, evbuffer_add_printf( body, "

%d: %s

", code, code_text ); if( text ) - evbuffer_add_printf( body, "

%s

", text ); + evbuffer_add_printf( body, "%s", text ); evhttp_send_reply( req, code, code_text, body ); evbuffer_free( body ); } @@ -320,25 +320,41 @@ static void handle_clutch( struct evhttp_request * req, struct tr_rpc_server * server ) { - char * pch; - char * subpath; - char * filename; const char * clutchDir = tr_getClutchDir( server->session ); assert( !strncmp( req->uri, "/transmission/web/", 18 ) ); - subpath = tr_strdup( req->uri + 18 ); - if(( pch = strchr( subpath, '?' ))) - *pch = '\0'; + if( !clutchDir || !*clutchDir ) + { + send_simple_response( req, HTTP_NOTFOUND, + "

Couldn't find Transmission's web interface files!

" + "

Users: to tell Transmission where to look, " + "set the TRANSMISSION_WEB_HOME environmental " + "variable to the folder where the web interface's " + "index.html is located.

" + "

Package Builders: to set a custom default at compile time, " + "#define PACKAGE_DATA_DIR in libtransmission/platform.c " + "or tweak tr_getClutchDir() by hand.

" ); + } + else + { + char * pch; + char * subpath; + char * filename; - filename = *subpath - ? tr_strdup_printf( "%s%s%s", clutchDir, TR_PATH_DELIMITER_STR, subpath ) - : tr_strdup_printf( "%s%s%s", clutchDir, TR_PATH_DELIMITER_STR, "index.html" ); + subpath = tr_strdup( req->uri + 18 ); + if(( pch = strchr( subpath, '?' ))) + *pch = '\0'; - serve_file( req, filename ); + filename = *subpath + ? tr_strdup_printf( "%s%s%s", clutchDir, TR_PATH_DELIMITER_STR, subpath ) + : tr_strdup_printf( "%s%s%s", clutchDir, TR_PATH_DELIMITER_STR, "index.html" ); - tr_free( filename ); - tr_free( subpath ); + serve_file( req, filename ); + + tr_free( filename ); + tr_free( subpath ); + } } static void