@@ -22,7 +22,7 @@ fn tainted_path_handler_good(Query(file_name): Query<String>) -> Result<String>
22
22
23
23
//#[handler]
24
24
fn 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 ") ;
26
26
let file_path = public_path. join ( PathBuf :: from ( file_path) ) ;
27
27
let file_path = file_path. canonicalize ( ) . unwrap ( ) ;
28
28
// 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
36
36
fn tainted_path_handler_folder_almost_good1 (
37
37
Query ( file_path) : Query < String > , // $ Source=remote4
38
38
) -> Result < String > {
39
- let public_path = home_dir ( ) . unwrap ( ) . join ( "public ") ;
39
+ let public_path = PathBuf :: from ( "/var/www/public_html ") ;
40
40
let file_path = public_path. join ( PathBuf :: from ( file_path) ) ;
41
41
// BAD: the path could still contain `..` and escape the public folder
42
42
if !file_path. starts_with ( public_path) {
@@ -49,7 +49,7 @@ fn tainted_path_handler_folder_almost_good1(
49
49
fn tainted_path_handler_folder_almost_good2 (
50
50
Query ( file_path) : Query < String > , // $ Source=remote5
51
51
) -> Result < String > {
52
- let public_path = home_dir ( ) . unwrap ( ) . join ( "public ") ;
52
+ let public_path = PathBuf :: from ( "/var/www/public_html ") ;
53
53
let file_path = public_path. join ( PathBuf :: from ( file_path) ) ;
54
54
let file_path = file_path. canonicalize ( ) . unwrap ( ) ;
55
55
// BAD: thecheck to ensure that the path stays within the public folder is wrong
0 commit comments