Browse Source

Merge pull request #21091 from nextcloud/sftp-normalize-path

normalize sftp path in read and write stream
Joas Schilling 3 years ago
parent
commit
33f6a26a7d

+ 3 - 0
apps/files_external/lib/Lib/Storage/SFTPReadStream.php

@@ -82,6 +82,9 @@ class SFTPReadStream implements File {
 
 	public function stream_open($path, $mode, $options, &$opened_path) {
 		[, $path] = explode('://', $path);
+		$path = '/' . ltrim($path);
+		$path = str_replace('//', '/', $path);
+
 		$this->loadContext('sftp');
 
 		if (!($this->sftp->bitmap & SSH2::MASK_LOGIN)) {

+ 3 - 0
apps/files_external/lib/Lib/Storage/SFTPWriteStream.php

@@ -82,6 +82,9 @@ class SFTPWriteStream implements File {
 
 	public function stream_open($path, $mode, $options, &$opened_path) {
 		[, $path] = explode('://', $path);
+		$path = '/' . ltrim($path);
+		$path = str_replace('//', '/', $path);
+
 		$this->loadContext('sftp');
 
 		if (!($this->sftp->bitmap & SSH2::MASK_LOGIN)) {