Skip to content

Commit bc6261f

Browse files
author
tolanych
committed
add log notify about trouble with ENV encoding
начинающиеся с «#» будут проигнорированы, а пустое сообщение
1 parent aad01d9 commit bc6261f

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

Diff for: core/model/modx/processors/browser/file/remove.class.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ public function process() {
3333
if (empty($file)) {
3434
return $this->modx->error->failure($this->modx->lexicon('file_err_ns'));
3535
}
36-
$oldlocale = setlocale(LC_ALL, 0);
37-
setlocale(LC_ALL,'C.UTF-8');
3836
$pathinfo = pathinfo($file);
39-
setlocale(LC_ALL,$oldlocale);
37+
if ($pathinfo['dirname'].DIRECTORY_SEPARATOR.$pathinfo['basename'] != $file) {
38+
$this->modx->log (modX::LOG_LEVEL_ERROR, 'Could not prepare the filepath ' . $file . '. Please set a valid UTF8 capable locale in the MODX system setting "locale".');
39+
}
4040
$directory = preg_replace('/[\.]{2,}/', '', htmlspecialchars($pathinfo['dirname']));
4141
$name = htmlspecialchars($pathinfo['basename']);
4242
$path = $directory.DIRECTORY_SEPARATOR.$name;

Diff for: core/model/modx/processors/browser/file/rename.class.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,22 @@ public function process() {
4040
}
4141

4242
$oldFile = $this->getProperty('path');
43-
$oldlocale = setlocale(LC_ALL, 0);
44-
setlocale(LC_ALL,'C.UTF-8');
4543
$pathinfo = pathinfo($oldFile);
44+
if ($pathinfo['dirname'].DIRECTORY_SEPARATOR.$pathinfo['basename'] != $oldFile) {
45+
$this->modx->log (modX::LOG_LEVEL_ERROR, 'Could not prepare the filepath ' . $oldFile . '. Please set a valid UTF8 capable locale in the MODX system setting "locale".');
46+
}
4647
$directory = preg_replace('/[\.]{2,}/', '', htmlspecialchars($pathinfo['dirname']));
4748
$name = htmlspecialchars($pathinfo['basename']);
4849
$oldFile = $directory.DIRECTORY_SEPARATOR.$name;
4950

5051
$newFile = $this->getProperty('name');
5152
$pathinfo = pathinfo($newFile);
53+
if ($pathinfo['basename'] != $newFile) {
54+
$this->modx->log (modX::LOG_LEVEL_ERROR, 'Could not prepare the filepath ' . $newFile . '. Please set a valid UTF8 capable locale in the MODX system setting "locale".');
55+
}
5256
$directory = preg_replace('/[\.]{2,}/', '', htmlspecialchars($pathinfo['dirname']));
5357
$name = htmlspecialchars($pathinfo['basename']);
5458
$newFile = $directory.DIRECTORY_SEPARATOR.$name;
55-
setlocale(LC_ALL,$oldlocale);
5659
$success = $this->source->renameObject($oldFile, $newFile);
5760

5861
if (empty($success)) {

0 commit comments

Comments
 (0)