Page MenuHomePhabricator

D14231.id34363.diff
No OneTemporary

D14231.id34363.diff

diff --git a/src/filesystem/Filesystem.php b/src/filesystem/Filesystem.php
--- a/src/filesystem/Filesystem.php
+++ b/src/filesystem/Filesystem.php
@@ -750,6 +750,13 @@
$root = realpath($root);
}
+ // NOTE: We don't use `isDescendant()` here because we don't want to reject
+ // paths which don't exist on disk.
+ $root_list = new FileList(array($root));
+ if (!$root_list->contains($path)) {
+ return array();
+ }
+
$walk = array();
$parts = explode(DIRECTORY_SEPARATOR, $path);
foreach ($parts as $k => $part) {
@@ -758,10 +765,6 @@
}
}
- if (!self::isDescendant($path, $root)) {
- return array();
- }
-
while ($parts) {
if (phutil_is_windows()) {
$next = implode(DIRECTORY_SEPARATOR, $parts);
diff --git a/src/filesystem/__tests__/FilesystemTestCase.php b/src/filesystem/__tests__/FilesystemTestCase.php
--- a/src/filesystem/__tests__/FilesystemTestCase.php
+++ b/src/filesystem/__tests__/FilesystemTestCase.php
@@ -110,6 +110,17 @@
dirname(__FILE__).'/data/include_dir.txt/subdir.txt',
array(),
),
+
+ 'fictional paths work' => array(
+ '/x/y/z',
+ '/',
+ array(
+ '/x/y/z',
+ '/x/y',
+ '/x',
+ ),
+ ),
+
);
foreach ($test_cases as $test_case) {

File Metadata

Mime Type
text/plain
Expires
Sat, Mar 8, 11:59 AM (2 w, 7 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7382182
Default Alt Text
D14231.id34363.diff (1 KB)

Event Timeline