Issue #3354095: "Check for existing subdirectory returns false positive when public files directory is a root directory or a symlink to a root directory"
4 open threads
Merge request reports
Activity
added 24 commits
-
94fea006...75ea9ab7 - 21 commits from branch
project:11.x
- c094140b - Apply patch from #1
- ec98a2e5 - Add a kernel test
- 92f982a3 - Avoid calling \stat() with FALSE
Toggle commit list-
94fea006...75ea9ab7 - 21 commits from branch
11 */ 12 class StreamWrapperCustomRootDirectoryTest extends FileTestBase { 13 14 /** 15 * Tests that the public stream wrapper can handle a custom root directory. 16 */ 17 public function testRealPathHandlesCustomRootDirectory(): void { 18 $this->setSetting('file_public_path', '/custom-dir'); 19 $this->assertDirectoryDoesNotExist("public://foo/custom-dir"); 20 } 21 22 } 23 24 } 25 26 namespace Drupal\Core\StreamWrapper { But this is totally ad-hoc for this test... it replaces realpath() and stat() functions in a very customized way to make this very test working. Indeed, I don't think it would be safe to add other tests in this class, which would make all
Drupal\Core\StreamWrapper
namespace code use those fake realpath() and stat() methods.Edited by Víctor Dorado
13 14 /** 15 * Tests that the public stream wrapper can handle a custom root directory. 16 */ 17 public function testRealPathHandlesCustomRootDirectory(): void { 18 $this->setSetting('file_public_path', '/custom-dir'); 19 $this->assertDirectoryDoesNotExist("public://foo/custom-dir"); 20 } 21 22 } 23 24 } 25 26 namespace Drupal\Core\StreamWrapper { 27 28 function realpath(string $path): string|false { 21 22 } 23 24 } 25 26 namespace Drupal\Core\StreamWrapper { 27 28 function realpath(string $path): string|false { 29 // Simulate that /custom-dir is an existing directory. 30 if (preg_match('/^\/custom-dir$/', $path)) { 31 return $path; 32 } 33 return \realpath($path); 34 } 35 36 function stat(string $filename): array|false { @smustgrave I've replied to your comments
added 1 commit
- 6a401872 - Attempt at adding documentation to the test.
added 443 commits
-
f27221de...ae796c66 - 436 commits from branch
project:11.x
- b01b18d0 - Apply patch from #1
- b0068dca - Add a kernel test
- c9192d4a - Avoid calling \stat() with FALSE
- 3082ba4a - Attempt at adding documentation to the test.
- 6661aa4e - Further tweaks to the code docblocks.
- d6ec445a - Oops, errors writing comments.
- cebe5427 - Fixing spelling errors in comments.
Toggle commit list-
f27221de...ae796c66 - 436 commits from branch
Please register or sign in to reply