nextcloud / previewgenerator

Nextcloud app to do preview generation in the background.
https://apps.nextcloud.com/apps/previewgenerator
GNU Affero General Public License v3.0
455 stars 57 forks source link

Unicode issues: umlauts in path are not working in some cases #261

Closed Sim0nW0lf closed 2 years ago

Sim0nW0lf commented 2 years ago

Configuration

My system is running Docker version 20.10.10, nextcloud:apache (currently v,22.2.0) with redis and Traefik in my docker-compose.yml on arm64 and also amd64 I use the previewgenerator app aswell as the camera raw preview app. These are the necessary components installed and the altered policies. Finally my preview settings in Nextclouds config.php.

Issue

The issue is, that RAW, tif, indd (all camerarawpreviews) images and MSOffice documents (maybe also others) throw errors instead of generating a preview if the path or filename contains any umlauts. (öäü) txt, md, odt, png, jpg, pdf work. I didn't test more, maybe there are some more that don't work.

Example 1:

image Logs:

[core] Error: unable to open image `/tmp/test.png': No such file or directory @ error/blob.c/OpenBlob/2924

GET /core/preview?fileId=250312&c=1248d325c58d97f7e6013764215d03ba&x=250&y=250&forceIcon=0&a=0
from 77.6.209.250 by root at 2021-11-12T17:16:46+00:00

{"reqId":"8rAq58Ukd7RRwoVnvqHD","level":3,"time":"2021-11-12T17:16:46+00:00","remoteAddr":"77.6.209.250","user":"root","app":"core","method":"GET","url":"/core/preview?fileId=250312&c=1248d325c58d97f7e6013764215d03ba&x=250&y=250&forceIcon=0&a=0","message":"unable to open image `/tmp/test.png': No such file or directory @ error/blob.c/OpenBlob/2924","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:94.0) Gecko/20100101 Firefox/94.0","version":"22.2.0.2","exception":{"Exception":"ImagickException","Message":"unable to open image `/tmp/test.png': No such file or directory @ error/blob.c/OpenBlob/2924","Code":435,"Trace":[{"file":"/var/www/html/lib/private/Preview/Office.php","line":64,"function":"__construct","class":"Imagick","type":"->","args":["/tmp/test.png[0]"]},{"file":"/var/www/html/lib/private/Preview/GeneratorHelper.php","line":62,"function":"getThumbnail","class":"OC\\Preview\\Office","type":"->","args":[{"__class__":"OC\\Files\\Node\\File"},2048,2048]},{"file":"/var/www/html/lib/private/Preview/Generator.php","line":245,"function":"getThumbnail","class":"OC\\Preview\\GeneratorHelper","type":"->","args":[{"__class__":"OC\\Preview\\MSOffice2007"},{"__class__":"OC\\Files\\Node\\File"},2048,2048]},{"file":"/var/www/html/lib/private/Preview/Generator.php","line":140,"function":"getMaxPreview","class":"OC\\Preview\\Generator","type":"->","args":[{"__class__":"OC\\Files\\SimpleFS\\SimpleFolder"},{"__class__":"OC\\Files\\Node\\File"},"application/vnd.openxmlformats-officedocument.wordprocessingml.document",""]},{"file":"/var/www/html/lib/private/Preview/Generator.php","line":109,"function":"generatePreviews","class":"OC\\Preview\\Generator","type":"->","args":[{"__class__":"OC\\Files\\Node\\File"},[{"width":250,"height":250,"crop":true,"mode":"fill"}],"application/vnd.openxmlformats-officedocument.wordprocessingml.document"]},{"file":"/var/www/html/lib/private/PreviewManager.php","line":189,"function":"getPreview","class":"OC\\Preview\\Generator","type":"->","args":[{"__class__":"OC\\Files\\Node\\File"},250,250,true,"fill",null]},{"file":"/var/www/html/core/Controller/PreviewController.php","line":169,"function":"getPreview","class":"OC\\PreviewManager","type":"->","args":[{"__class__":"OC\\Files\\Node\\File"},250,250,true,"fill"]},{"file":"/var/www/html/core/Controller/PreviewController.php","line":142,"function":"fetchPreview","class":"OC\\Core\\Controller\\PreviewController","type":"->","args":[{"__class__":"OC\\Files\\Node\\File"},250,250,false,false,"fill"]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":217,"function":"getPreviewByFileId","class":"OC\\Core\\Controller\\PreviewController","type":"->","args":[250312,250,250,false,false,"fill"]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":126,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OC\\Core\\Controller\\PreviewController"},"getPreviewByFileId"]},{"file":"/var/www/html/lib/private/AppFramework/App.php","line":156,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OC\\Core\\Controller\\PreviewController"},"getPreviewByFileId"]},{"file":"/var/www/html/lib/private/Route/Router.php","line":301,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OC\\Core\\Controller\\PreviewController","getPreviewByFileId",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},{"_route":"core.Preview.getPreviewByFileId"}]},{"file":"/var/www/html/lib/base.php","line":1000,"function":"match","class":"OC\\Route\\Router","type":"->","args":["/core/preview"]},{"file":"/var/www/html/index.php","line":36,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"/var/www/html/lib/private/Preview/Office.php","Line":64,"CustomMessage":"--"},"id":"618ea17f50c8c"}

[PHP] Error: unlink(/tmp/test.png): No such file or directory at /var/www/html/lib/private/Preview/Office.php#68

GET /core/preview?fileId=250312&c=1248d325c58d97f7e6013764215d03ba&x=250&y=250&forceIcon=0&a=0
from 77.6.209.250 by root at 2021-11-12T17:16:46+00:00

{"reqId":"8rAq58Ukd7RRwoVnvqHD","level":3,"time":"2021-11-12T17:16:46+00:00","remoteAddr":"77.6.209.250","user":"root","app":"PHP","method":"GET","url":"/core/preview?fileId=250312&c=1248d325c58d97f7e6013764215d03ba&x=250&y=250&forceIcon=0&a=0","message":"unlink(/tmp/test.png): No such file or directory at /var/www/html/lib/private/Preview/Office.php#68","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:94.0) Gecko/20100101 Firefox/94.0","version":"22.2.0.2","exception":{"Exception":"Error","Message":"unlink(/tmp/test.png): No such file or directory at /var/www/html/lib/private/Preview/Office.php#68","Code":0,"Trace":[{"function":"onError","class":"OC\\Log\\ErrorHandler","type":"::","args":[2,"unlink(/tmp/test.png): No such file or directory","/var/www/html/lib/private/Preview/Office.php",68]},{"file":"/var/www/html/lib/private/Preview/Office.php","line":68,"function":"unlink","args":["/tmp/test.png"]},{"file":"/var/www/html/lib/private/Preview/GeneratorHelper.php","line":62,"function":"getThumbnail","class":"OC\\Preview\\Office","type":"->","args":[{"__class__":"OC\\Files\\Node\\File"},2048,2048]},{"file":"/var/www/html/lib/private/Preview/Generator.php","line":245,"function":"getThumbnail","class":"OC\\Preview\\GeneratorHelper","type":"->","args":[{"__class__":"OC\\Preview\\MSOffice2007"},{"__class__":"OC\\Files\\Node\\File"},2048,2048]},{"file":"/var/www/html/lib/private/Preview/Generator.php","line":140,"function":"getMaxPreview","class":"OC\\Preview\\Generator","type":"->","args":[{"__class__":"OC\\Files\\SimpleFS\\SimpleFolder"},{"__class__":"OC\\Files\\Node\\File"},"application/vnd.openxmlformats-officedocument.wordprocessingml.document",""]},{"file":"/var/www/html/lib/private/Preview/Generator.php","line":109,"function":"generatePreviews","class":"OC\\Preview\\Generator","type":"->","args":[{"__class__":"OC\\Files\\Node\\File"},[{"width":250,"height":250,"crop":true,"mode":"fill"}],"application/vnd.openxmlformats-officedocument.wordprocessingml.document"]},{"file":"/var/www/html/lib/private/PreviewManager.php","line":189,"function":"getPreview","class":"OC\\Preview\\Generator","type":"->","args":[{"__class__":"OC\\Files\\Node\\File"},250,250,true,"fill",null]},{"file":"/var/www/html/core/Controller/PreviewController.php","line":169,"function":"getPreview","class":"OC\\PreviewManager","type":"->","args":[{"__class__":"OC\\Files\\Node\\File"},250,250,true,"fill"]},{"file":"/var/www/html/core/Controller/PreviewController.php","line":142,"function":"fetchPreview","class":"OC\\Core\\Controller\\PreviewController","type":"->","args":[{"__class__":"OC\\Files\\Node\\File"},250,250,false,false,"fill"]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":217,"function":"getPreviewByFileId","class":"OC\\Core\\Controller\\PreviewController","type":"->","args":[250312,250,250,false,false,"fill"]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":126,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OC\\Core\\Controller\\PreviewController"},"getPreviewByFileId"]},{"file":"/var/www/html/lib/private/AppFramework/App.php","line":156,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OC\\Core\\Controller\\PreviewController"},"getPreviewByFileId"]},{"file":"/var/www/html/lib/private/Route/Router.php","line":301,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OC\\Core\\Controller\\PreviewController","getPreviewByFileId",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},{"_route":"core.Preview.getPreviewByFileId"}]},{"file":"/var/www/html/lib/base.php","line":1000,"function":"match","class":"OC\\Route\\Router","type":"->","args":["/core/preview"]},{"file":"/var/www/html/index.php","line":36,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"/var/www/html/lib/private/Log/ErrorHandler.php","Line":92,"CustomMessage":"--"},"id":"618ea17f50d00"}

Example 2:

image logs:

[camerarawpreviews] Error: Unable to find preview data: /usr/bin/perl /var/www/html/custom_apps/camerarawpreviews/vendor/exiftool/exiftool/exiftool -json -preview:all -FileType '/media/ncdata/root/files/umlauts /DSC01740.ARW' -> 

GET /core/preview?fileId=250428&c=8d12c65ae12ad141ad691665e7a7a98c&x=250&y=250&forceIcon=0&a=0
from 77.6.209.250 by root at 2021-11-12T17:26:21+00:00

{"reqId":"G8Jz1uJTRQKjLAVjamyv","level":3,"time":"2021-11-12T17:26:21+00:00","remoteAddr":"77.6.209.250","user":"root","app":"camerarawpreviews","method":"GET","url":"/core/preview?fileId=250428&c=8d12c65ae12ad141ad691665e7a7a98c&x=250&y=250&forceIcon=0&a=0","message":"Unable to find preview data: /usr/bin/perl /var/www/html/custom_apps/camerarawpreviews/vendor/exiftool/exiftool/exiftool -json -preview:all -FileType '/media/ncdata/root/files/umlauts /DSC01740.ARW' -> ","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:94.0) Gecko/20100101 Firefox/94.0","version":"22.2.0.2","exception":{"Exception":"Exception","Message":"Unable to find preview data: /usr/bin/perl /var/www/html/custom_apps/camerarawpreviews/vendor/exiftool/exiftool/exiftool -json -preview:all -FileType '/media/ncdata/root/files/umlauts /DSC01740.ARW' -> ","Code":0,"Trace":[{"file":"/var/www/html/custom_apps/camerarawpreviews/lib/RawPreviewBase.php","line":111,"function":"getBestPreviewTag","class":"OCA\\CameraRawPreviews\\RawPreviewBase","type":"->","args":["/media/ncdata/root/files/umlauts öä/DSC01740.ARW"]},{"file":"/var/www/html/custom_apps/camerarawpreviews/lib/RawPreviewBase.php","line":61,"function":"getResizedPreview","class":"OCA\\CameraRawPreviews\\RawPreviewBase","type":"->","args":["/media/ncdata/root/files/umlauts öä/DSC01740.ARW",2048,2048]},{"file":"/var/www/html/custom_apps/camerarawpreviews/lib/RawPreviewIProviderV2.php","line":25,"function":"getThumbnailInternal","class":"OCA\\CameraRawPreviews\\RawPreviewBase","type":"->","args":[{"__class__":"OC\\Files\\Node\\File"},2048,2048]},{"file":"/var/www/html/lib/private/Preview/GeneratorHelper.php","line":62,"function":"getThumbnail","class":"OCA\\CameraRawPreviews\\RawPreviewIProviderV2","type":"->","args":[{"__class__":"OC\\Files\\Node\\File"},2048,2048]},{"file":"/var/www/html/lib/private/Preview/Generator.php","line":245,"function":"getThumbnail","class":"OC\\Preview\\GeneratorHelper","type":"->","args":[{"__class__":"OCA\\CameraRawPreviews\\RawPreviewIProviderV2"},{"__class__":"OC\\Files\\Node\\File"},2048,2048]},{"file":"/var/www/html/lib/private/Preview/Generator.php","line":140,"function":"getMaxPreview","class":"OC\\Preview\\Generator","type":"->","args":[{"__class__":"OC\\Files\\SimpleFS\\SimpleFolder"},{"__class__":"OC\\Files\\Node\\File"},"image/x-dcraw",""]},{"file":"/var/www/html/lib/private/Preview/Generator.php","line":109,"function":"generatePreviews","class":"OC\\Preview\\Generator","type":"->","args":[{"__class__":"OC\\Files\\Node\\File"},[{"width":250,"height":250,"crop":true,"mode":"fill"}],"image/x-dcraw"]},{"file":"/var/www/html/lib/private/PreviewManager.php","line":189,"function":"getPreview","class":"OC\\Preview\\Generator","type":"->","args":[{"__class__":"OC\\Files\\Node\\File"},250,250,true,"fill",null]},{"file":"/var/www/html/core/Controller/PreviewController.php","line":169,"function":"getPreview","class":"OC\\PreviewManager","type":"->","args":[{"__class__":"OC\\Files\\Node\\File"},250,250,true,"fill"]},{"file":"/var/www/html/core/Controller/PreviewController.php","line":142,"function":"fetchPreview","class":"OC\\Core\\Controller\\PreviewController","type":"->","args":[{"__class__":"OC\\Files\\Node\\File"},250,250,false,false,"fill"]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":217,"function":"getPreviewByFileId","class":"OC\\Core\\Controller\\PreviewController","type":"->","args":[250428,250,250,false,false,"fill"]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":126,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OC\\Core\\Controller\\PreviewController"},"getPreviewByFileId"]},{"file":"/var/www/html/lib/private/AppFramework/App.php","line":156,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OC\\Core\\Controller\\PreviewController"},"getPreviewByFileId"]},{"file":"/var/www/html/lib/private/Route/Router.php","line":301,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OC\\Core\\Controller\\PreviewController","getPreviewByFileId",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},{"_route":"core.Preview.getPreviewByFileId"}]},{"file":"/var/www/html/lib/base.php","line":1000,"function":"match","class":"OC\\Route\\Router","type":"->","args":["/core/preview"]},{"file":"/var/www/html/index.php","line":36,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"/var/www/html/custom_apps/camerarawpreviews/lib/RawPreviewBase.php","Line":196,"CustomMessage":"--"},"id":"618ea3bda77c2"}

Is this a configuration issue on my side or a bug?

Sim0nW0lf commented 2 years ago

Downgrading to NC Version 22.1.0 fixes the issues for me. That is a temporary solution!

Sim0nW0lf commented 2 years ago

Weirdly on most of my servers that didn't create office previews for some reason... This is how I made it work consistently: (I am building my Instance with a dockerfile, so there I have to change the version. You might have to edit your docker-compose or whatever you use instead)

First I had to downgrade to version 21.0-apache like this:

  1. cd /docker/nextcloud/
  2. docker-compose down
  3. docker image prune -a
  4. nano app/Dockerfile change version nextcloud:21.0-apache, tags can be found on dockerhub
  5. nano Container-Data/html/config/config.php change 'version' to 21.0.0.0
  6. nano Container-Data/html/version.php change $OC_Version to 21,0,0,0 and $OC_VersionString to 21.0.0
  7. docker-compose up -d

After that's up and running I upgraded again:

  1. docker-compose down
  2. nano app/Dockerfile change version to nextcloud:22.1.0-apache
  3. docker-compose up -d --build

Now check if everything is running correctly and office previews are being generated again! If everything works you can clean up the containers using docker image prune -a

st3iny commented 2 years ago

Duplicate of https://github.com/nextcloud/server/issues/29296. The fix is at https://github.com/nextcloud/server/pull/29695. It will be included in the next update release of Nextcloud v21, v22 and v23.