Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15331624
D14231.id34363.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D14231.id34363.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D14231: Allow Filesystem::walkToRoot() to operate on fictional paths
Attached
Detach File
Event Timeline
Log In to Comment