Skip to content

Commit 80066f1

Browse files
authored
Merge pull request #1260 from patacra/bugfix/739-move-item-on-windows-crashes
Fix `Lfm::translateFromUtf8()` to handle an array of strings and not only a string.
2 parents 45018d1 + c59fdd1 commit 80066f1

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/Lfm.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,15 +226,21 @@ public function allowShareFolder()
226226
}
227227

228228
/**
229-
* Translate file name to make it compatible on Windows.
229+
* Translate file or directory name(s) to be compatible on Windows.
230230
*
231-
* @param string $input Any string.
232-
* @return string
231+
* @param string|array $input Any string or array of strings.
232+
* @return string|array
233233
*/
234234
public function translateFromUtf8($input)
235235
{
236236
if ($this->isRunningOnWindows()) {
237-
$input = iconv('UTF-8', mb_detect_encoding($input), $input);
237+
if (is_array($input)) {
238+
foreach ($input as &$item) {
239+
$item = iconv('UTF-8', mb_detect_encoding($item), $item);
240+
}
241+
} else {
242+
$input = iconv('UTF-8', mb_detect_encoding($input), $input);
243+
}
238244
}
239245

240246
return $input;

0 commit comments

Comments
 (0)