@@ -22,7 +22,7 @@ fn tainted_path_handler_good(Query(file_name): Query<String>) -> Result<String>
2222
2323//#[handler]
2424fn tainted_path_handler_folder_good ( Query ( file_path) : Query < String > ) -> Result < String > {
25- let public_path = home_dir ( ) . unwrap ( ) . join ( "public ") ;
25+ let public_path = PathBuf :: from ( "/var/www/public_html ") ;
2626 let file_path = public_path. join ( PathBuf :: from ( file_path) ) ;
2727 let file_path = file_path. canonicalize ( ) . unwrap ( ) ;
2828 // GOOD: ensure that the path stays within the public folder
@@ -36,7 +36,7 @@ fn tainted_path_handler_folder_good(Query(file_path): Query<String>) -> Result<S
3636fn tainted_path_handler_folder_almost_good1 (
3737 Query ( file_path) : Query < String > , // $ Source=remote4
3838) -> Result < String > {
39- let public_path = home_dir ( ) . unwrap ( ) . join ( "public ") ;
39+ let public_path = PathBuf :: from ( "/var/www/public_html ") ;
4040 let file_path = public_path. join ( PathBuf :: from ( file_path) ) ;
4141 // BAD: the path could still contain `..` and escape the public folder
4242 if !file_path. starts_with ( public_path) {
@@ -49,7 +49,7 @@ fn tainted_path_handler_folder_almost_good1(
4949fn tainted_path_handler_folder_almost_good2 (
5050 Query ( file_path) : Query < String > , // $ Source=remote5
5151) -> Result < String > {
52- let public_path = home_dir ( ) . unwrap ( ) . join ( "public ") ;
52+ let public_path = PathBuf :: from ( "/var/www/public_html ") ;
5353 let file_path = public_path. join ( PathBuf :: from ( file_path) ) ;
5454 let file_path = file_path. canonicalize ( ) . unwrap ( ) ;
5555 // BAD: thecheck to ensure that the path stays within the public folder is wrong
0 commit comments