Skip to content

Commit

Permalink
fix(TextareaField): use ealpath to rename tmp file and do not change …
Browse files Browse the repository at this point in the history
…text on rename failure
  • Loading branch information
J9rem committed Jul 11, 2022
1 parent 76493ab commit 5c7fe74
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tools/bazar/fields/TextareaField.php
Expand Up @@ -241,8 +241,13 @@ private function sanitizeAttach(string $text, array $entry): string
'user' => '',
];
$newFileName = $attach->GetFullFilename(true);
rename($previousFileName, $newFileName);
$text = str_replace($matches[0][$key], $matches[1][$key].$matches[4][$key].$matches[5][$key], $text);
$dirRealPath = realpath(dirname($previousFileName));
if (rename(
$dirRealPath . DIRECTORY_SEPARATOR . basename($previousFileName),
$dirRealPath . DIRECTORY_SEPARATOR . basename($newFileName)
)) {
$text = str_replace($matches[0][$key], $matches[1][$key].$matches[4][$key].$matches[5][$key], $text);
}
unset($attach);
$wiki->tag = $previousTag;
$wiki->page = $previousPage;
Expand Down

0 comments on commit 5c7fe74

Please sign in to comment.