Skip to content

Commit 4b7e74b

Browse files
committed
Allow for temp folder to be prefixed with /private
Mac OS X puts some of the system folders like `/var` and `/tmp` into a special hidden `/private` folder. When checking whether the folder to delete is indeed within a temp folder (as a safeguard), we should also allow for a version of the temp folder prefixed with `/private`.
1 parent 83b636f commit 4b7e74b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

features/steps/given.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ function ( $world, $empty_or_nonexistent, $dir ) {
2424

2525
$temp_dir = sys_get_temp_dir();
2626

27-
if ( 0 !== strpos( $dir, $temp_dir ) ) {
27+
// Also check for temp dir prefixed with `/private` for Mac OS X.
28+
if ( 0 !== strpos( $dir, $temp_dir ) && 0 !== strpos( $dir, "/private{$temp_dir}" ) ) {
2829
throw new RuntimeException( sprintf( "Attempted to delete directory '%s' that is not in the temp directory '%s'. " . __FILE__ . ':' . __LINE__, $dir, $temp_dir ) );
2930
}
3031

0 commit comments

Comments
 (0)