Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ONLYOFFICE/onlyoffice-nextcloud.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Linnik <sergey.linnik@onlyoffice.com>2022-10-20 12:30:10 +0300
committerSergey Linnik <sergey.linnik@onlyoffice.com>2022-10-20 16:10:11 +0300
commit1b5759ce62d1cfe59906b10737c45cb80081f80a (patch)
treefe07571f43a7787e4567c4ba837e139709a0cfaa
parent5fdf15850b57cdb6e509c253944569b23c4c1db6 (diff)
Fix path lookup and version number (Fix #717 Close #718)feature/version-thumbnail
-rw-r--r--lib/fileversions.php10
-rw-r--r--lib/preview.php3
2 files changed, 8 insertions, 5 deletions
diff --git a/lib/fileversions.php b/lib/fileversions.php
index 2ff4782..3ed43a5 100644
--- a/lib/fileversions.php
+++ b/lib/fileversions.php
@@ -71,13 +71,13 @@ class FileVersions {
* @return array
*/
public static function splitPathVersion($pathVersion) {
- $pos = strrpos($pathVersion, ".v");
- if ($pos === false) {
+ if (empty($pathVersion)) {
return false;
}
- $filePath = substr($pathVersion, 0, $pos);
- $versionId = substr($pathVersion, 2 + $pos - strlen($pathVersion));
- return [$filePath, $versionId];
+ if (preg_match("/(.+)\.v(\d+)$/", $pathVersion, $matches)) {
+ return [$matches[1], $matches[2]];
+ }
+ return false;
}
/**
diff --git a/lib/preview.php b/lib/preview.php
index 1cbd608..fef14c8 100644
--- a/lib/preview.php
+++ b/lib/preview.php
@@ -360,6 +360,9 @@ class Preview extends Provider {
$relativePath = $versionFolder->getRelativePath($absolutePath);
list ($filePath, $fileVersion) = FileVersions::splitPathVersion($relativePath);
+ if ($filePath === null) {
+ return [null, null, null];
+ }
$sourceFile = $this->root->getUserFolder($owner->getUID())->get($filePath);