HugoHasenbein / redmine_more_previews

Redmine plugin to preview various file types in redmine's preview pane
https://www.redmine.org/plugins/redmine_more_previews
GNU General Public License v2.0
46 stars 15 forks source link

email preview fails when email has attachments #92

Open batrachian opened 11 months ago

batrachian commented 11 months ago

email preview is working for .eml files attached to issues when the email does not include attachments.

When the email includes attachments, an error is displayed instead of the email body. e.g. (partial traceback):

No such file or directory @ rb_sysopen - /usr/local/www/redmine/tmp/more_previews/attachments/593/preview.html/image005.png
/usr/local/lib/ruby/gems/3.1/gems/marcel-1.0.2/lib/marcel/mime_type.rb:64:in `initialize'
/usr/local/lib/ruby/gems/3.1/gems/marcel-1.0.2/lib/marcel/mime_type.rb:64:in `open'
/usr/local/lib/ruby/gems/3.1/gems/marcel-1.0.2/lib/marcel/mime_type.rb:64:in `open'
/usr/local/lib/ruby/gems/3.1/gems/marcel-1.0.2/lib/marcel/mime_type.rb:64:in `with_io'
/usr/local/lib/ruby/gems/3.1/gems/marcel-1.0.2/lib/marcel/mime_type.rb:30:in `for_data'
/usr/local/lib/ruby/gems/3.1/gems/marcel-1.0.2/lib/marcel/mime_type.rb:17:in `for'
/usr/local/www/redmine/plugins/redmine_more_previews/lib/redmine_more_previews/patches/attachment_patch.rb:102:in `asset_link'
/usr/local/lib/ruby/gems/3.1/gems/activesupport-6.1.7.6/lib/active_support/core_ext/object/try.rb:15:in `public_send'
/usr/local/lib/ruby/gems/3.1/gems/activesupport-6.1.7.6/lib/active_support/core_ext/object/try.rb:15:in `try'
(erb):5:in `block in list'
(erb):2:in `each'
(erb):2:in `list'
/usr/local/lib/ruby/3.1/erb.rb:905:in `eval'
/usr/local/lib/ruby/3.1/erb.rb:905:in `result'
/usr/local/www/redmine/plugins/redmine_more_previews/converters/cliff/lib/cliff.rb:378:in `list'
/usr/local/www/redmine/plugins/redmine_more_previews/converters/cliff/lib/cliff.rb:93:in `eml'
/usr/local/www/redmine/plugins/redmine_more_previews/converters/cliff/lib/cliff.rb:46:in `convert'
/usr/local/www/redmine/plugins/redmine_more_previews/lib/redmine_more_previews/conversion.rb:193:in `block in transient_preview'
/usr/local/lib/ruby/3.1/tmpdir.rb:96:in `mktmpdir'
/usr/local/www/redmine/plugins/redmine_more_previews/lib/redmine_more_previews/conversion.rb:186:in `transient_preview'
/usr/local/www/redmine/plugins/redmine_more_previews/lib/redmine_more_previews/conversion.rb:169:in `block in preview'
/usr/local/www/redmine/plugins/redmine_more_previews/lib/redmine_more_previews/conversion.rb:137:in `synchronize'
/usr/local/www/redmine/plugins/redmine_more_previews/lib/redmine_more_previews/conversion.rb:137:in `sync'
/usr/local/www/redmine/plugins/redmine_more_previews/lib/redmine_more_previews/conversion.rb:169:in `preview'
/usr/local/www/redmine/plugins/redmine_more_previews/lib/redmine_more_previews/converter.rb:265:in `convert'
/usr/local/www/redmine/plugins/redmine_more_previews/lib/redmine_more_previews/patches/attachment_patch.rb:37:in `more_preview'
/usr/local/www/redmine/plugins/redmine_more_previews/lib/redmine_more_previews/patches/attachments_controller_patch.rb:99:in `send_more_preview'
/usr/local/www/redmine/plugins/redmine_more_previews/lib/redmine_more_previews/patches/attachments_controller_patch.rb:61:in `block (2 levels) in more_preview'
/usr/local/lib/ruby/gems/3.1/gems/actionpack-6.1.7.6/lib/action_controller/metal/mime_responds.rb:214:in `respond_to'
/usr/local/www/redmine/plugins/redmine_more_previews/lib/redmine_more_previews/patches/attachments_controller_patch.rb:60:in `more_preview'
/usr/local/lib/ruby/gems/3.1/gems/actionpack-6.1.7.6/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
/usr/local/lib/ruby/gems/3.1/gems/actionpack-6.1.7.6/lib/abstract_controller/base.rb:228:in `process_action'
/usr/local/lib/ruby/gems/3.1/gems/actionpack-6.1.7.6/lib/action_controller/metal/rendering.rb:30:in `process_action'
/usr/local/lib/ruby/gems/3.1/gems/actionpack-6.1.7.6/lib/abstract_controller/callbacks.rb:42:in `block in process_action'
/usr/local/lib/ruby/gems/3.1/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb:117:in `block in run_callbacks'
/usr/local/www/redmine/lib/redmine/sudo_mode.rb:61:in `sudo_mode'

The more_previews directory does not exist in /usr/local/www/redmine/tmp/

(other directories in tmp - e.g. cache, thumbnails - have recently modified files in them, so tmp is writeable by redmine.

If the directory /usr/local/www/redmine/tmp/more_previews/attachments/593/preview.html/ is manually created, the error message becomes:

No such file or directory @ rb_sysopen - image005.png
/usr/local/lib/ruby/gems/3.1/gems/marcel-1.0.2/lib/marcel/mime_type.rb:64:in `initialize'
<... rest of traceback>

The error still occurs even if the directory preview.html is made world-writeable.

I tried making the change suggested in https://github.com/HugoHasenbein/redmine_more_previews/issues/87 but this did not help.

Does anyone have any suggestions of a likely cause?

batrachian commented 11 months ago

@HugoHasenbein do you have any suggestions of what to look at to diagnose this further? Is there other info to provide that might assist an investigation?

HugoHasenbein commented 11 months ago

I suspect it is an issue of the character encoding of the local file system. The filename is provided in the email with an arbitrary character encoding and the plugin fails to adapt the filename encoding to the local file system encoding. For that, it might fail if the local system does not support that encoding. Redmine has already addressed this issue by having a means to select the encoding of the local file system in the "File System Repository Setting". This is a rough guess, though.

Am 20.10.2023 um 08:50 schrieb batrachian @.***>:

@HugoHasenbein https://github.com/HugoHasenbein do you have any suggestions of what to look at to diagnose this further? Is there other info to provide that might assist an investigation?

— Reply to this email directly, view it on GitHub https://github.com/HugoHasenbein/redmine_more_previews/issues/92#issuecomment-1772181790, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJWRDRBK3NHDWIKQLPYUHPDYAINM3AVCNFSM6AAAAAA54GHJCCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONZSGE4DCNZZGA. You are receiving this because you were mentioned.