nextcloud / server

☁️ Nextcloud server, a safe home for all your data
https://nextcloud.com
GNU Affero General Public License v3.0
26.73k stars 4k forks source link

[Bug]: TypeError: `fileInfo1[key].localeCompare` is not a function - Error while opening an image on browser #47736

Open NeptuneHub opened 1 week ago

NeptuneHub commented 1 week ago

⚠️ This issue respects the following points: ⚠️

Bug description

From PC (windows) /Smartphone (Android) chrome browser, only on the directory /Camera of user admin, I can see the image/video in the folder (the thumbs) but when I click on it to expand I have a black windows and the error below.

Image/video in other folder of the same user are ok. Image/video in other folder of other user are ok. Priviledge and ownership of the image/video seems the same of both image viewed and not viewed: -rwxrwxr-x 1 www-data www-data

The same image/video on Android app is open without any problem.

I try by deleting nextcloud, reinstalling it, re-put the image folder in it, re-create the previwe, but the problem persist. I try by deleting the chrome cache, by opening an incognito windows, but the problem persist.

The folder is the main folder with a big number of photo and video, but I have another user with another big folder that don't have this problem. So I'm not recognizing any pattern for now.

Logs and error

Chrome console log (error):

viewer-main.mjs?v=b70227db-0:24502 Could not open file /Camera/IMG_20240517_095548884_HDR_AE.jpg TypeError: fileInfo1[key].localeCompare is not a function
    at sortCompare (viewer-main.mjs?v=b70227db-0:23115:116)
    at viewer-main.mjs?v=b70227db-0:24549:56
    at Array.sort (<anonymous>)
    at VueComponent.openFileInfo (viewer-main.mjs?v=b70227db-0:24549:39)
    at async VueComponent.openFile (viewer-main.mjs?v=b70227db-0:24495:9)

Chrome network log (seems not error in it):

Request URL:
https://store2.silverycat.de/remote.php/dav/files/admin/Camera/IMG_20240517_095548884_HDR_AE.jpg
Request Method:
PROPFIND
Status Code:
207 Multi-Status
Remote Address:
216.247.153.177:443
Referrer Policy:
no-referrer

Describe your Environment

nodeSelector: kubernetes.io/hostname: ubuntu1

Number of replicas to be deployed

replicaCount: 1 ingress: enabled: true className: traefik annotations: cert-manager.io/cluster-issuer: letsencrypt-production acme.cert-manager.io/http01-edit-in-place: "true" tls:

nginx: enabled: false image: repository: nginx tag: alpine pullPolicy: IfNotPresent containerPort: 80 persistence: enabled: true annotations: {} storageClass: "manual" #"smb" #"local-path" existingClaim: nextcloud-config-pvc nextcloudData: enabled: true annotations: {} storageClass: "manual" existingClaim: nextcloud-server-pvc

phpClientHttpsFix: enabled: true protocol: https

resources: requests: memory: "512Mi" # Start with a conservative estimate cpu: "500m" # This is 0.5 CPU core limits: memory: "2Gi" # Allow up to 2 GiB of memory usage cpu: "1500m" # Allow up to 2 CPU cores

startupProbe: enabled: true initialDelaySeconds: 120 failureThreshold: 50

lifecycle: postStartCommand: ["/bin/bash", "-c", "apt update -y && apt install ffmpeg -y"]


I'm using local-path PVC on the root disk (an SSD attached by USB 3).
Only app installed on top of the helm chart are imagepreview and memories.

Also this is the config.php:

<?php $CONFIG = array ( 'htaccess.RewriteBase' => '/', 'memcache.local' => '\OC\Memcache\APCu', 'apps_paths' => array ( 0 => array ( 'path' => '/var/www/html/apps', 'url' => '/apps', 'writable' => false, ), 1 => array ( 'path' => '/var/www/html/custom_apps', 'url' => '/custom_apps', 'writable' => true, ), ), 'overwriteprotocol' => 'https', 'upgrade.disable-web' => true, 'passwordsalt' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'trusted_domains' => array ( 0 => 'localhost', 1 => '', ), 'datadirectory' => '/var/www/html/data', 'dbtype' => 'sqlite3', 'version' => '29.0.6.1', 'overwrite.cli.url' => 'https://localhost', 'dbname' => 'nextcloud', 'installed' => true, 'instanceid' => 'oc1fa7yyp42d', 'memories.db.triggers.fcu' => true, 'memories.exiftool' => '/var/www/html/custom_apps/memories/bin-ext/exiftool-aarch64-glibc', 'memories.vod.path' => '/var/www/html/custom_apps/memories/bin-ext/go-vod-aarch64', 'memories.vod.ffmpeg' => '/usr/bin/ffmpeg', 'memories.vod.ffprobe' => '/usr/bin/ffprobe', 'enable_previews' => true, 'jpeg_quality' => '60', 'preview_max_x' => '1024', 'preview_max_y' => '1024', 'preview_max_scale_factor' => 1.5, 'enabledPreviewProviders' => array ( 0 => 'OC\Preview\MP3', 1 => 'OC\Preview\TXT', 2 => 'OC\Preview\MarkDown', 3 => 'OC\Preview\OpenDocument', 4 => 'OC\Preview\Krita', 5 => 'OC\Preview\Imaginary', 6 => 'OC\Preview\PDF', 7 => 'OC\Preview\Movie', 8 => 'OC\Preview\MKV', 9 => 'OC\Preview\MP4', 10 => 'OC\Preview\AVI', 11 => 'OC\Preview\JPEG', 12 => 'OC\Preview\PNG', 13 => 'OC\Preview\GIF', 14 => 'OC\Preview\BMP', 15 => 'OC\Preview\XBitmap', 16 => 'OC\Preview\HEIC', 17 => 'OC\Preview\TIFF', 18 => 'OC\Preview\Image', 19 => 'OC\Preview\FFmpeg', ), 'preview_ffmpeg_path' => '/usr/bin/ffmpeg', 'preview_imaginary_url' => 'http://imaginary.imaginary.svc.cluster.local:9000', 'filelocking.enabled' => false, 'allow_local_remote_servers' => true, 'memories.ffmpeg_path' => '/usr/bin/ffmpeg', 'loglevel' => 0, 'maintenance' => false, );



### Steps to reproduce

I wasn't able to reproduce a pattern: Just clicking on an image/video on a specific folder in the brower and it open a black windows instead of the image/video itself.

### Expected behavior

When you click on the image you should view the "bigger version", if you click on a video, it should start the video reproduction.

### Nextcloud Server version

29

### Operating system

Debian/Ubuntu

### PHP engine version

PHP 8.3

### Web server

Apache (supported)

### Database engine version

SQlite

### Is this bug present after an update or on a fresh install?

None

### Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

### What user-backends are you using?

- [X] Default user-backend _(database)_
- [ ] LDAP/ Active Directory
- [ ] SSO - SAML
- [ ] Other

### Configuration report

_No response_

### List of activated Apps

_No response_

### Nextcloud Signing status

_No response_

### Nextcloud Logs

_No response_

### Additional info

_No response_
thlehmann-ionos commented 6 days ago

Please provide an example folder structure and sorting order with which this can be reproduced. This probably depends on what else is present in the folder, not just the file to be opened.

thlehmann-ionos commented 6 days ago

Note: in fileUtils.ts in genFileInfo() it's problematic to test any field to be numeric (castable to Number) and then converting it to number. Whether or not this is the case here (steps to reproduce inadequate), I can see, that this leads to problems if the basename attribute happens to be a file or folder name which resembles a number (i.e. "123"). When casted to type Number later comparisons in sort functions will fail due to Number not implementing localCompare(). Whatever the steps to reproduce are here, genFileInfo() should be more specific/careful when converting types from the server responses.

Side note: this is an error in the Viewer app (which has its own issue tracker).

NeptuneHub commented 6 days ago

Hi, The folder Camera was directly in the root of my admin account, so I had something like: /data/admin/files/Camera

the file in it was photo and video uploaded from an android smartphone, so this is some filename example (are underd of file, so is difficult to report everyone):

-rwxrwx--- 1 www-data www-data 6491196 Sep 6 05:08 IMG_20240906_070857474.jpg -rwxrwx--- 1 www-data www-data 6058092 Sep 6 05:09 IMG_20240906_070858248.jpg -rwxrwx--- 1 www-data www-data 6113377 Sep 6 05:09 IMG_20240906_070858889.jpg -rwxrwx--- 1 www-data www-data 6067141 Sep 6 05:09 IMG_20240906_070859471.jpg -rwxrwx--- 1 www-data www-data 5252887 Sep 6 05:09 IMG_20240906_070900281.jpg -rwxrwx--- 1 www-data www-data 3598502 Sep 6 20:01 IMG_20240906_220100824.jpg -rwxrwx--- 1 www-data www-data 3708989 Sep 6 21:41 IMG_20240906_234116201.jpg -rw-rw-r-- 1 www-data www-data 4016992 Sep 8 07:24 IMG_20240908_092414773_HDR.jpg -rw-r--r-- 1 www-data www-data 5103377 Sep 8 14:45 IMG_20240908_164526358.jpg -rw-r--r-- 1 www-data www-data 2545943 Sep 8 14:45 IMG_20240908_164540399.jpg -rw-r--r-- 1 www-data www-data 4194684 Sep 8 14:46 IMG_20240908_164603386.jpg -rw-r--r-- 1 www-data www-data 3165621 Sep 8 14:46 IMG_20240908_164620841_HDR.jpg -rw-r--r-- 1 www-data www-data 3491388 Sep 8 14:46 IMG_20240908_164628269_HDR.jpg -rw-r--r-- 1 www-data www-data 2620522 Sep 9 16:17 IMG_20240909_181728171_HDR.jpg -rw-r--r-- 1 www-data www-data 3651992 Sep 9 16:19 IMG_20240909_181932709_HDR.jpg -rw-r--r-- 1 www-data www-data 2809257 Sep 9 16:19 IMG_20240909_181949856_HDR.jpg -rwxrwx--- 1 www-data www-data 138121755 Nov 28 2023 VID_20231128_112153160.mp4 -rwxrwx--- 1 www-data www-data 95770954 Nov 28 2023 VID_20231128_112404456.mp4 -rwxrwx--- 1 www-data www-data 160584884 Dec 2 2023 VID_20231202_224916058~2.mp4

trying to disinstall and reinstall it didn't solve the problem.

Instead I solved he problem (for now) by cancelling the folder, creating a new one with the name "Foto" and then re-upload everything from the smartphone.

Maybe there was one file that create this problem that I didn't re-create by uploading everything from zero?

If the problem re-apper I'll check better filename.