Normalize temp dir in Given a directory step#329
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Code Review
This pull request updates the temporary directory handling in GivenStepDefinitions.php to resolve macOS path normalization issues by incorporating realpath() and stripping the /private/var/ prefix. The review feedback recommends extending the path normalization to include /private/tmp/ to ensure consistency and refactoring the directory assignment logic for better readability.
| $dir = Path::normalize( $dir ); | ||
|
|
||
| // Also normalize temp dir for Mac OS X. | ||
| $temp_dir = preg_replace( '|^/private/var/|', '/var/', $temp_dir ); |
There was a problem hiding this comment.
On macOS, /tmp is also a symbolic link to /private/tmp. Since realpath() is now used, it might return /private/tmp if the system temp directory is set to /tmp (or if TMPDIR is set to /tmp). To avoid potential regressions in the security check on line 64, the regex should also handle the /private/tmp/ prefix, similar to how it handles /private/var/.
$temp_dir = preg_replace( '|^/private/(var|tmp)/|', '/$1/', $temp_dir );| $temp_dir = realpath( sys_get_temp_dir() ); | ||
| $temp_dir = $temp_dir ? Path::normalize( $temp_dir ) : Path::normalize( sys_get_temp_dir() ); |
No description provided.