Skip to content

Commit bdc1f4e

Browse files
committed
fix(files_external): skip BSD ftpd "total N" listing headers
BSD ftpd prepends directory listings with a `total N` line. The raw LIST parser treated that as a file entry and threw, so external FTP storage against FreeBSD could not be browsed. Skip empty lines and `total` headers the same way flysystem does, while still parsing `.` / `..` as cdir/pdir. Fixes: #37045 Signed-off-by: Xusnitdinov Azizbek <252487890+xusnitdinov@users.noreply.github.com>
1 parent be98f77 commit bdc1f4e

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

apps/files_external/lib/Lib/Storage/FtpConnection.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,15 @@ public function mlsd(string $path) {
121121

122122
// rawlist parsing logic is based on the ftp implementation from https://github.com/thephpleague/flysystem
123123
private function parseRawList(array $rawList, string $directory): array {
124+
$filtered = array_values(array_filter($rawList, static function (string $item): bool {
125+
$item = trim($item);
126+
// BSD ftpd (and some Unix servers) prepend listings with a "total N" header
127+
return $item !== '' && !preg_match('/^total\b/i', $item);
128+
}));
129+
124130
return array_map(function ($item) use ($directory) {
125131
return $this->parseRawListItem($item, $directory);
126-
}, $rawList);
132+
}, $filtered);
127133
}
128134

129135
private function parseRawListItem(string $item, string $directory): array {

0 commit comments

Comments
 (0)