@@ -176,7 +176,6 @@ private static function getVersionsSize($user) {
176176 * store a new version of a file.
177177 */
178178 public static function store ($ filename ) {
179-
180179 // if the file gets streamed we need to remove the .part extension
181180 // to get the right target
182181 $ ext = pathinfo ($ filename , PATHINFO_EXTENSION );
@@ -357,7 +356,6 @@ public static function renameOrCopy($sourcePath, $targetPath, $operation) {
357356 * @return bool
358357 */
359358 public static function rollback (string $ file , int $ revision , IUser $ user ) {
360-
361359 // add expected leading slash
362360 $ filename = '/ ' . ltrim ($ file , '/ ' );
363361
@@ -495,11 +493,21 @@ public static function getVersions($uid, $filename, $userFullPath = '') {
495493 $ filename = $ pathparts ['filename ' ];
496494 if ($ filename === $ versionedFile ) {
497495 $ pathparts = pathinfo ($ entryName );
498- $ timestamp = substr ($ pathparts ['extension ' ], 1 );
496+ $ timestamp = substr ($ pathparts ['extension ' ] ?? '' , 1 );
497+ if (!is_numeric ($ timestamp )) {
498+ \OC ::$ server ->get (LoggerInterface::class)->error (
499+ 'Version file {path} has incorrect name format ' ,
500+ [
501+ 'path ' => $ entryName ,
502+ 'app ' => 'files_versions ' ,
503+ ]
504+ );
505+ continue ;
506+ }
499507 $ filename = $ pathparts ['filename ' ];
500508 $ key = $ timestamp . '# ' . $ filename ;
501509 $ versions [$ key ]['version ' ] = $ timestamp ;
502- $ versions [$ key ]['humanReadableTimestamp ' ] = self ::getHumanReadableTimestamp ($ timestamp );
510+ $ versions [$ key ]['humanReadableTimestamp ' ] = self ::getHumanReadableTimestamp (( int ) $ timestamp );
503511 if (empty ($ userFullPath )) {
504512 $ versions [$ key ]['preview ' ] = '' ;
505513 } else {
@@ -577,7 +585,7 @@ public static function expireOlderThanMaxForUser($uid) {
577585 * @param int $timestamp
578586 * @return string for example "5 days ago"
579587 */
580- private static function getHumanReadableTimestamp ($ timestamp ) {
588+ private static function getHumanReadableTimestamp (int $ timestamp ): string {
581589 $ diff = time () - $ timestamp ;
582590
583591 if ($ diff < 60 ) { // first minute
0 commit comments