aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/l10n/ja.js2
-rw-r--r--lib/l10n/ja.json2
-rw-r--r--lib/l10n/pt_BR.js6
-rw-r--r--lib/l10n/pt_BR.json6
-rw-r--r--lib/private/Files/Cache/Cache.php2
-rw-r--r--lib/private/Installer.php45
-rw-r--r--lib/private/Preview/Generator.php2
-rw-r--r--lib/private/legacy/OC_Helper.php65
-rw-r--r--lib/public/Util.php44
9 files changed, 108 insertions, 66 deletions
diff --git a/lib/l10n/ja.js b/lib/l10n/ja.js
index 820aec1a2ba..06aad919ff3 100644
--- a/lib/l10n/ja.js
+++ b/lib/l10n/ja.js
@@ -93,6 +93,8 @@ OC.L10N.register(
"Destination does not exist" : "宛先が存在しません",
"Destination is not creatable" : "宛先は作成できません",
"Dot files are not allowed" : "隠しファイルは許可されていません",
+ "%1$s (renamed)" : "%1$s (リネーム済み)",
+ "renamed file" : "リネーム済みファイル",
"\"%1$s\" is a forbidden file or folder name." : "\"%1$s\"は禁止されているファイル名またはフォルダー名です。",
"\"%1$s\" is a forbidden prefix for file or folder names." : "\"%1$s\"は、ファイル名やフォルダー名には使用できない接頭辞です。",
"\"%1$s\" is not allowed inside a file or folder name." : "\"%1$s\"はファイル名やフォルダー名の中に入れることはできません。",
diff --git a/lib/l10n/ja.json b/lib/l10n/ja.json
index 04f6e2ee13d..f0328f6d484 100644
--- a/lib/l10n/ja.json
+++ b/lib/l10n/ja.json
@@ -91,6 +91,8 @@
"Destination does not exist" : "宛先が存在しません",
"Destination is not creatable" : "宛先は作成できません",
"Dot files are not allowed" : "隠しファイルは許可されていません",
+ "%1$s (renamed)" : "%1$s (リネーム済み)",
+ "renamed file" : "リネーム済みファイル",
"\"%1$s\" is a forbidden file or folder name." : "\"%1$s\"は禁止されているファイル名またはフォルダー名です。",
"\"%1$s\" is a forbidden prefix for file or folder names." : "\"%1$s\"は、ファイル名やフォルダー名には使用できない接頭辞です。",
"\"%1$s\" is not allowed inside a file or folder name." : "\"%1$s\"はファイル名やフォルダー名の中に入れることはできません。",
diff --git a/lib/l10n/pt_BR.js b/lib/l10n/pt_BR.js
index bf7f7728be6..4b6c3ae36b7 100644
--- a/lib/l10n/pt_BR.js
+++ b/lib/l10n/pt_BR.js
@@ -306,7 +306,7 @@ OC.L10N.register(
"This is probably caused by a cache/accelerator such as Zend OPcache or eAccelerator." : "Isso provavelmente é causado por um cache/acelerador, como Zend OPcache ou eAccelerator.",
"PHP modules have been installed, but they are still listed as missing?" : "Módulos do PHP foram instalados, mas eles ainda estão listados como faltantes?",
"Please ask your server administrator to restart the web server." : "Por favor peça ao administrador do servidor para reiniciar o servidor web.",
- "The required %s config variable is not configured in the config.php file." : "A variável %s de configuração necessária não está configurada no arquivo config.php.",
+ "The required %s config variable is not configured in the config.php file." : "A variável de configuração %s obrigatória não está configurada no arquivo config.php.",
"Please ask your server administrator to check the Nextcloud configuration." : "Peça ao administrador do servidor para verificar a configuração do Nextcloud.",
"Your data directory is readable by other people." : "Seu diretório de dados pode ser lido por outras pessoas.",
"Please change the permissions to 0770 so that the directory cannot be listed by other people." : "Altere as permissões para 0770 para que o diretório não possa ser listado por outras pessoas.",
@@ -400,12 +400,12 @@ OC.L10N.register(
"Tool calls" : "Chamadas de ferramentas",
"Tools call instructions from the model in JSON format" : "Instruções de chamada de ferramentas do modelo no formato JSON",
"Formalize text" : "Formalizar texto",
- "Takes a text and makes it sound more formal" : "Pega um texto e faz com que ele soe mais formal",
+ "Takes a text and makes it sound more formal" : "Pega um texto e o faz parecer mais formal",
"Write a text that you want the assistant to formalize" : "Escreva um texto que você deseja que o assistente formalize",
"Formalized text" : "Texto formalizado",
"The formalized text" : "O texto formalizado",
"Generate a headline" : "Gere um título",
- "Generates a possible headline for a text." : "Gera um título possível para um texto.",
+ "Generates a possible headline for a text." : "Gera um possível título para um texto.",
"Original text" : "Texto original",
"The original text to generate a headline for" : "O texto original para gerar um título para",
"The generated headline" : "O título gerado",
diff --git a/lib/l10n/pt_BR.json b/lib/l10n/pt_BR.json
index ad7df10df2b..47f04ec37db 100644
--- a/lib/l10n/pt_BR.json
+++ b/lib/l10n/pt_BR.json
@@ -304,7 +304,7 @@
"This is probably caused by a cache/accelerator such as Zend OPcache or eAccelerator." : "Isso provavelmente é causado por um cache/acelerador, como Zend OPcache ou eAccelerator.",
"PHP modules have been installed, but they are still listed as missing?" : "Módulos do PHP foram instalados, mas eles ainda estão listados como faltantes?",
"Please ask your server administrator to restart the web server." : "Por favor peça ao administrador do servidor para reiniciar o servidor web.",
- "The required %s config variable is not configured in the config.php file." : "A variável %s de configuração necessária não está configurada no arquivo config.php.",
+ "The required %s config variable is not configured in the config.php file." : "A variável de configuração %s obrigatória não está configurada no arquivo config.php.",
"Please ask your server administrator to check the Nextcloud configuration." : "Peça ao administrador do servidor para verificar a configuração do Nextcloud.",
"Your data directory is readable by other people." : "Seu diretório de dados pode ser lido por outras pessoas.",
"Please change the permissions to 0770 so that the directory cannot be listed by other people." : "Altere as permissões para 0770 para que o diretório não possa ser listado por outras pessoas.",
@@ -398,12 +398,12 @@
"Tool calls" : "Chamadas de ferramentas",
"Tools call instructions from the model in JSON format" : "Instruções de chamada de ferramentas do modelo no formato JSON",
"Formalize text" : "Formalizar texto",
- "Takes a text and makes it sound more formal" : "Pega um texto e faz com que ele soe mais formal",
+ "Takes a text and makes it sound more formal" : "Pega um texto e o faz parecer mais formal",
"Write a text that you want the assistant to formalize" : "Escreva um texto que você deseja que o assistente formalize",
"Formalized text" : "Texto formalizado",
"The formalized text" : "O texto formalizado",
"Generate a headline" : "Gere um título",
- "Generates a possible headline for a text." : "Gera um título possível para um texto.",
+ "Generates a possible headline for a text." : "Gera um possível título para um texto.",
"Original text" : "Texto original",
"The original text to generate a headline for" : "O texto original para gerar um título para",
"The generated headline" : "O título gerado",
diff --git a/lib/private/Files/Cache/Cache.php b/lib/private/Files/Cache/Cache.php
index 2c190720c23..cb160115851 100644
--- a/lib/private/Files/Cache/Cache.php
+++ b/lib/private/Files/Cache/Cache.php
@@ -663,7 +663,7 @@ class Cache implements ICache {
$sourceData = $sourceCache->get($sourcePath);
if (!$sourceData) {
- throw new \Exception('Invalid source storage path: ' . $sourcePath);
+ throw new \Exception('Source path not found in cache: ' . $sourcePath);
}
$shardDefinition = $this->connection->getShardDefinition('filecache');
diff --git a/lib/private/Installer.php b/lib/private/Installer.php
index a1d27c9255b..f32b0e5919a 100644
--- a/lib/private/Installer.php
+++ b/lib/private/Installer.php
@@ -16,8 +16,8 @@ use OC\AppFramework\Bootstrap\Coordinator;
use OC\Archive\TAR;
use OC\DB\Connection;
use OC\DB\MigrationService;
+use OC\Files\FilenameValidator;
use OC_App;
-use OC_Helper;
use OCP\App\IAppManager;
use OCP\Files;
use OCP\HintException;
@@ -25,6 +25,7 @@ use OCP\Http\Client\IClientService;
use OCP\IConfig;
use OCP\ITempManager;
use OCP\Migration\IOutput;
+use OCP\Server;
use phpseclib\File\X509;
use Psr\Log\LoggerInterface;
@@ -242,6 +243,10 @@ class Installer {
// Download the release
$tempFile = $this->tempManager->getTemporaryFile('.tar.gz');
+ if ($tempFile === false) {
+ throw new \RuntimeException('Could not create temporary file for downloading app archive.');
+ }
+
$timeout = $this->isCLI ? 0 : 120;
$client = $this->clientService->newClient();
$client->get($app['releases'][0]['download'], ['sink' => $tempFile, 'timeout' => $timeout]);
@@ -253,8 +258,11 @@ class Installer {
if ($verified === true) {
// Seems to match, let's proceed
$extractDir = $this->tempManager->getTemporaryFolder();
- $archive = new TAR($tempFile);
+ if ($extractDir === false) {
+ throw new \RuntimeException('Could not create temporary directory for unpacking app.');
+ }
+ $archive = new TAR($tempFile);
if (!$archive->extract($extractDir)) {
$errorMessage = 'Could not extract app ' . $appId;
@@ -329,9 +337,9 @@ class Installer {
// Move to app folder
if (@mkdir($baseDir)) {
$extractDir .= '/' . $folders[0];
- OC_Helper::copyr($extractDir, $baseDir);
}
- OC_Helper::copyr($extractDir, $baseDir);
+ // otherwise we just copy the outer directory
+ $this->copyRecursive($extractDir, $baseDir);
Files::rmdirr($extractDir);
return;
}
@@ -588,4 +596,33 @@ class Installer {
include $script;
}
}
+
+ /**
+ * Recursive copying of local folders.
+ *
+ * @param string $src source folder
+ * @param string $dest target folder
+ */
+ private function copyRecursive(string $src, string $dest): void {
+ if (!file_exists($src)) {
+ return;
+ }
+
+ if (is_dir($src)) {
+ if (!is_dir($dest)) {
+ mkdir($dest);
+ }
+ $files = scandir($src);
+ foreach ($files as $file) {
+ if ($file != '.' && $file != '..') {
+ $this->copyRecursive("$src/$file", "$dest/$file");
+ }
+ }
+ } else {
+ $validator = Server::get(FilenameValidator::class);
+ if (!$validator->isForbidden($src)) {
+ copy($src, $dest);
+ }
+ }
+ }
}
diff --git a/lib/private/Preview/Generator.php b/lib/private/Preview/Generator.php
index 00fc3b43d61..4a7341896ef 100644
--- a/lib/private/Preview/Generator.php
+++ b/lib/private/Preview/Generator.php
@@ -165,7 +165,7 @@ class Generator {
$maxPreviewImage = $this->helper->getImage($maxPreview);
}
- $this->logger->warning('Cached preview not found for file {path}, generating a new preview.', ['path' => $file->getPath()]);
+ $this->logger->debug('Cached preview not found for file {path}, generating a new preview.', ['path' => $file->getPath()]);
$preview = $this->generatePreview($previewFolder, $maxPreviewImage, $width, $height, $crop, $maxWidth, $maxHeight, $previewVersion, $cacheResult);
// New file, augment our array
$previewFiles[] = $preview;
diff --git a/lib/private/legacy/OC_Helper.php b/lib/private/legacy/OC_Helper.php
index 172c865364c..6caab38b784 100644
--- a/lib/private/legacy/OC_Helper.php
+++ b/lib/private/legacy/OC_Helper.php
@@ -66,6 +66,7 @@ class OC_Helper {
* @param string $src source folder
* @param string $dest target folder
* @return void
+ * @deprecated 32.0.0 - use \OCP\Files\Folder::copy
*/
public static function copyr($src, $dest) {
if (!file_exists($src)) {
@@ -131,7 +132,7 @@ class OC_Helper {
$exts = [''];
$check_fn = 'is_executable';
// Default check will be done with $path directories :
- $dirs = explode(PATH_SEPARATOR, $path);
+ $dirs = explode(PATH_SEPARATOR, (string)$path);
// WARNING : We have to check if open_basedir is enabled :
$obd = OC::$server->get(IniGetWrapper::class)->getString('open_basedir');
if ($obd != 'none') {
@@ -246,49 +247,30 @@ class OC_Helper {
/**
* Returns an array with all keys from input lowercased or uppercased. Numbered indices are left as is.
+ * Based on https://www.php.net/manual/en/function.array-change-key-case.php#107715
*
* @param array $input The array to work on
* @param int $case Either MB_CASE_UPPER or MB_CASE_LOWER (default)
* @param string $encoding The encoding parameter is the character encoding. Defaults to UTF-8
* @return array
- *
- * Returns an array with all keys from input lowercased or uppercased. Numbered indices are left as is.
- * based on https://www.php.net/manual/en/function.array-change-key-case.php#107715
- *
+ * @deprecated 4.5.0 use \OCP\Util::mb_array_change_key_case instead
*/
public static function mb_array_change_key_case($input, $case = MB_CASE_LOWER, $encoding = 'UTF-8') {
- $case = ($case != MB_CASE_UPPER) ? MB_CASE_LOWER : MB_CASE_UPPER;
- $ret = [];
- foreach ($input as $k => $v) {
- $ret[mb_convert_case($k, $case, $encoding)] = $v;
- }
- return $ret;
+ return \OCP\Util::mb_array_change_key_case($input, $case, $encoding);
}
/**
- * performs a search in a nested array
+ * Performs a search in a nested array.
+ * Taken from https://www.php.net/manual/en/function.array-search.php#97645
+ *
* @param array $haystack the array to be searched
* @param string $needle the search string
* @param mixed $index optional, only search this key name
* @return mixed the key of the matching field, otherwise false
- *
- * performs a search in a nested array
- *
- * taken from https://www.php.net/manual/en/function.array-search.php#97645
+ * @deprecated 4.5.0 - use \OCP\Util::recursiveArraySearch
*/
public static function recursiveArraySearch($haystack, $needle, $index = null) {
- $aIt = new RecursiveArrayIterator($haystack);
- $it = new RecursiveIteratorIterator($aIt);
-
- while ($it->valid()) {
- if (((isset($index) and ($it->key() == $index)) or !isset($index)) and ($it->current() == $needle)) {
- return $aIt->key();
- }
-
- $it->next();
- }
-
- return false;
+ return \OCP\Util::recursiveArraySearch($haystack, $needle, $index);
}
/**
@@ -297,12 +279,10 @@ class OC_Helper {
* @param string $dir the current folder where the user currently operates
* @param int|float $freeSpace the number of bytes free on the storage holding $dir, if not set this will be received from the storage directly
* @return int|float number of bytes representing
+ * @deprecated 5.0.0 - use \OCP\Util::maxUploadFilesize
*/
public static function maxUploadFilesize($dir, $freeSpace = null) {
- if (is_null($freeSpace) || $freeSpace < 0) {
- $freeSpace = self::freeSpace($dir);
- }
- return min($freeSpace, self::uploadLimit());
+ return \OCP\Util::maxUploadFilesize($dir, $freeSpace);
}
/**
@@ -310,33 +290,20 @@ class OC_Helper {
*
* @param string $dir the current folder where the user currently operates
* @return int|float number of bytes representing
+ * @deprecated 7.0.0 - use \OCP\Util::freeSpace
*/
public static function freeSpace($dir) {
- $freeSpace = \OC\Files\Filesystem::free_space($dir);
- if ($freeSpace < \OCP\Files\FileInfo::SPACE_UNLIMITED) {
- $freeSpace = max($freeSpace, 0);
- return $freeSpace;
- } else {
- return (INF > 0)? INF: PHP_INT_MAX; // work around https://bugs.php.net/bug.php?id=69188
- }
+ return \OCP\Util::freeSpace($dir);
}
/**
* Calculate PHP upload limit
*
* @return int|float PHP upload file size limit
+ * @deprecated 7.0.0 - use \OCP\Util::uploadLimit
*/
public static function uploadLimit() {
- $ini = \OC::$server->get(IniGetWrapper::class);
- $upload_max_filesize = Util::computerFileSize($ini->get('upload_max_filesize')) ?: 0;
- $post_max_size = Util::computerFileSize($ini->get('post_max_size')) ?: 0;
- if ($upload_max_filesize === 0 && $post_max_size === 0) {
- return INF;
- } elseif ($upload_max_filesize === 0 || $post_max_size === 0) {
- return max($upload_max_filesize, $post_max_size); //only the non 0 value counts
- } else {
- return min($upload_max_filesize, $post_max_size);
- }
+ return \OCP\Util::uploadLimit();
}
/**
diff --git a/lib/public/Util.php b/lib/public/Util.php
index 979e7abe609..b3111c54fc7 100644
--- a/lib/public/Util.php
+++ b/lib/public/Util.php
@@ -491,7 +491,12 @@ class Util {
* @since 4.5.0
*/
public static function mb_array_change_key_case($input, $case = MB_CASE_LOWER, $encoding = 'UTF-8') {
- return \OC_Helper::mb_array_change_key_case($input, $case, $encoding);
+ $case = ($case != MB_CASE_UPPER) ? MB_CASE_LOWER : MB_CASE_UPPER;
+ $ret = [];
+ foreach ($input as $k => $v) {
+ $ret[mb_convert_case($k, $case, $encoding)] = $v;
+ }
+ return $ret;
}
/**
@@ -505,7 +510,18 @@ class Util {
* @deprecated 15.0.0
*/
public static function recursiveArraySearch($haystack, $needle, $index = null) {
- return \OC_Helper::recursiveArraySearch($haystack, $needle, $index);
+ $aIt = new \RecursiveArrayIterator($haystack);
+ $it = new \RecursiveIteratorIterator($aIt);
+
+ while ($it->valid()) {
+ if (((isset($index) and ($it->key() == $index)) or !isset($index)) and ($it->current() == $needle)) {
+ return $aIt->key();
+ }
+
+ $it->next();
+ }
+
+ return false;
}
/**
@@ -517,7 +533,10 @@ class Util {
* @since 5.0.0
*/
public static function maxUploadFilesize(string $dir, int|float|null $free = null): int|float {
- return \OC_Helper::maxUploadFilesize($dir, $free);
+ if (is_null($free) || $free < 0) {
+ $free = self::freeSpace($dir);
+ }
+ return min($free, self::uploadLimit());
}
/**
@@ -527,7 +546,13 @@ class Util {
* @since 7.0.0
*/
public static function freeSpace(string $dir): int|float {
- return \OC_Helper::freeSpace($dir);
+ $freeSpace = \OC\Files\Filesystem::free_space($dir);
+ if ($freeSpace < \OCP\Files\FileInfo::SPACE_UNLIMITED) {
+ $freeSpace = max($freeSpace, 0);
+ return $freeSpace;
+ } else {
+ return (INF > 0)? INF: PHP_INT_MAX; // work around https://bugs.php.net/bug.php?id=69188
+ }
}
/**
@@ -537,7 +562,16 @@ class Util {
* @since 7.0.0
*/
public static function uploadLimit(): int|float {
- return \OC_Helper::uploadLimit();
+ $ini = Server::get(IniGetWrapper::class);
+ $upload_max_filesize = self::computerFileSize($ini->get('upload_max_filesize')) ?: 0;
+ $post_max_size = self::computerFileSize($ini->get('post_max_size')) ?: 0;
+ if ($upload_max_filesize === 0 && $post_max_size === 0) {
+ return INF;
+ } elseif ($upload_max_filesize === 0 || $post_max_size === 0) {
+ return max($upload_max_filesize, $post_max_size); //only the non 0 value counts
+ } else {
+ return min($upload_max_filesize, $post_max_size);
+ }
}
/**