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
48 stars 17 forks source link

Internal error for .eml files with reciever/ sender name or subject containing umlauts #28

Open Boy132 opened 3 years ago

Boy132 commented 3 years ago

Problem: Some .eml Attachments throw an internal error because of the encoding. Sadly I can not provide a file thats causing the issue as the content is confidential but the mail's content-type is text/html; charset=iso-8859-1 and just contains simple text and one image. I will try to reproduce the problem with a mail I'm allowed to share.

Logs: https://hastebin.com/peduqivama.apache

Completed 500 Internal Server Error in 37ms (ActiveRecord: 1.6ms)

ActionView::Template::Error (incompatible character encodings: UTF-8 and ASCII-8BIT): 10: <\p><%= "#{@attachment.description} - " unless @attachment.description.blank? %> 11: <\span class="author"><%= link_to_user(@attachment.author) %>, <%= format_time(@attachment.created_on) %><\/span><\/p> 12: <\/div> 13: <\div class="filecontent-container"> 14: <%= yield %> 15: <\/div> 16:

app/views/layouts/_file.html.erb:13:in _app_views_layouts__file_html_erb___2146738585999283111_70271290998160' plugins/redmine_more_previews/app/views/attachments/more_preview.html.erb:8:in_plugins_redmine_more_previews_app_views_attachments_more_preview_html_erb___3601269883393320117_47383025699560' plugins/redmine_more_previews/lib/redmine_more_previews/patches/attachments_controller_patch.rb:143:in `show_with_more_previews'

Environment: Redmine version - 4.2.1.stable Ruby version - 2.5.5-p157 (2019-03-15) [x86_64-linux-gnu] Rails version - 5.2.5 Environment - production Database adapter - Mysql2 Mailer queue - ActiveJob::QueueAdapters::AsyncAdapter Mailer delivery - smtp

Boy132 commented 3 years ago

The name is the problem because it contains a "ö": From: =?iso-8859-1?Q?Sch=F6nau?= <snip> Or Subject: =?iso-8859-1?Q?CO2-Feuerl=F6scher_?= Thread-Topic: =?iso-8859-1?Q?CO2-Feuerl=F6scher_?=

Characters like ä, ö and ü in the name of the reciever/ sender or the subjekt seem to cause this issue.

HugoHasenbein commented 3 years ago

Dear Boy,

I am investigating on this. It seems, the way, the attachment is added to Redmine may help me to find the error. According to your logfiles the attachment contains ASCII-8-BIT text in the attachment's attribute 'description', which breaks in app/views/layouts/_file.html.erb:1, which is part of the core of Redmine. So the culprit is the program that writes the .eml attachment to the database. Please, can you tell me how you add the .eml file to Redmine?

best regards

Stephan

Am 22.07.2021 um 09:18 schrieb Boy132 @.***>:

Problem: Some .eml Attachments throw an internal error because of the econding. Sadly I can not provide a file thats causing the issue as the content is confidential but the mail's content-type is text/html; charset=iso-8859-1 and just contains simple text and one image. I will try to reproduce the problem with a mail I'm allowed to share.

Logs: https://hastebin.com/arokomelit.apache https://hastebin.com/arokomelit.apache Environment: Redmine version - 4.2.1.stable Ruby version - 2.5.5-p157 (2019-03-15) [x86_64-linux-gnu] Rails version - 5.2.5 Environment - production Database adapter - Mysql2 Mailer queue - ActiveJob::QueueAdapters::AsyncAdapter Mailer delivery - smtp

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/HugoHasenbein/redmine_more_previews/issues/28, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJWRDRDRMULKFHE7UYADPL3TY7A37ANCNFSM5AZNK3GQ.

HugoHasenbein commented 3 years ago

The message is camouflaged, which I understand. But it seems, the problem causing name has been -snipped- away as well.

Am 11.08.2021 um 10:52 schrieb Boy132 @.***>:

message.zip https://github.com/HugoHasenbein/redmine_more_previews/files/6967045/message.zip See the attached file for an example.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/HugoHasenbein/redmine_more_previews/issues/28#issuecomment-896633326, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJWRDRA2WFHG757FZVKFJMDT4I245ANCNFSM5AZNK3GQ. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email.

Boy132 commented 3 years ago

Dear Boy, I am investigating on this. It seems, the way, the attachment is added to Redmine may help me to find the error. According to your logfiles the attachment contains ASCII-8-BIT text in the attachment's attribute 'description', which breaks in app/views/layouts/_file.html.erb:1, which is part of the core of Redmine. So the culprit is the program that writes the .eml attachment to the database. Please, can you tell me how you add the .eml file to Redmine? best regards Stephan

The .eml file is normally added as attachment.

The message is camouflaged, which I understand. But it seems, the problem causing name has been -snipped- away as well.

Editing the .eml and manually change the subject or sender to the examples I gave above will reproduce the bug. (From: =?iso-8859-1?Q?Sch=F6nau?= or Subject: =?iso-8859-1?Q?CO2-Feuerl=F6scher_?=)

HugoHasenbein commented 3 years ago

Dear Boy,

try Version 2.0.7, now on GitHub. It should resolve the non-ascii headers issue in 'cliff'. I hope, this change does not reintroduce an old windows problem.

Best regards

Stephan

Am 18.08.2021 um 17:44 schrieb Boy132 @.***>:

Dear Boy, I am investigating on this. It seems, the way, the attachment is added to Redmine may help me to find the error. According to your logfiles the attachment contains ASCII-8-BIT text in the attachment's attribute 'description', which breaks in app/views/layouts/_file.html.erb:1, which is part of the core of Redmine. So the culprit is the program that writes the .eml attachment to the database. Please, can you tell me how you add the .eml file to Redmine? best regards Stephan

The .eml file is normally added as attachment.

The message is camouflaged, which I understand. But it seems, the problem causing name has been -snipped- away as well.

Editing the .eml and manually change the subject or sender to the examples I gave above will reproduce the bug. (From: =?iso-8859-1?Q?Sch=F6nau?= or Subject: =?iso-8859-1?Q?CO2-Feuerl=F6scher_?=)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/HugoHasenbein/redmine_more_previews/issues/28#issuecomment-901222745, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJWRDRCNCCIUA56ODBVYHPDT5PINNANCNFSM5AZNK3GQ. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email.

Boy132 commented 3 years ago

try Version 2.0.7, now on GitHub. It should resolve the non-ascii headers issue in 'cliff'.

I tested 2.0.7 and it did not resolve the problem. Still the same error: production.log

Boy132 commented 3 years ago

I also just realized that 2.0.7 breaks the Email body a bit: grafik Without the changes (2.0.6) it looks like this: grafik

Boy132 commented 3 years ago

Also loading the attachment "unsafe" works fine. redmine.url/attachments/1024?unsafe=1

Boy132 commented 3 years ago

Any news on this?

jcatrysse commented 2 years ago

I seem to have the same issue on « production » however on « test » this is working fine (though, I only get the email body, not the headers and attachments). Adding the « unsafe » parameter in the URL works fine.

HugoHasenbein commented 2 years ago

first time, this behavior is posted here. I assume, there might be a configuration error, if it runs with "test" but not with "production".

The development environment usually reloads classes in lib from file whenever all internal relations to the class are released. This eases programming a lot, as it makes restarting the server unnecessary, but which costs performance.

Attached is a screen shot: how emails should look like. The red arrow points to a link, which reaveals all other headers.

If you like to experiment:

in rails root dir enter:

grep -r unloadable plugins/redmine_more_previews/

it should result in

plugins/redmine_more_previews/lib/redmine_more_previews/patches/attachment_patch.rb: unloadable plugins/redmine_more_previews/lib/redmine_more_previews/patches/application_helper_patch.rb: unloadable plugins/redmine_more_previews/lib/redmine_more_previews/patches/entry_patch.rb: unloadable plugins/redmine_more_previews/lib/redmine_more_previews/patches/mime_type_patch.rb: unloadable plugins/redmine_more_previews/lib/redmine_more_previews/patches/repository_patch.rb: unloadable plugins/redmine_more_previews/lib/redmine_more_previews/patches/attachments_controller_patch.rb: unloadable plugins/redmine_more_previews/lib/redmine_more_previews/patches/admin_controller_patch.rb: unloadable plugins/redmine_more_previews/lib/redmine_more_previews/patches/repositories_controller_patch.rb: unloadable

then enter

grep -rl unloadable plugins/redmine_more_previews/ | xargs -i@ sed -i 's/unloadable/#unloadable/g' @

this uncomments unloadable patches

now

grep -r unloadable plugins/redmine_more_previews/

should result in

plugins/redmine_more_previews/lib/redmine_more_previews/patches/attachment_patch.rb: #unloadable plugins/redmine_more_previews/lib/redmine_more_previews/patches/application_helper_patch.rb: #unloadable plugins/redmine_more_previews/lib/redmine_more_previews/patches/entry_patch.rb: #unloadable plugins/redmine_more_previews/lib/redmine_more_previews/patches/mime_type_patch.rb: #unloadable plugins/redmine_more_previews/lib/redmine_more_previews/patches/repository_patch.rb: #unloadable plugins/redmine_more_previews/lib/redmine_more_previews/patches/attachments_controller_patch.rb: #unloadable plugins/redmine_more_previews/lib/redmine_more_previews/patches/admin_controller_patch.rb: #unloadable plugins/redmine_more_previews/lib/redmine_more_previews/patches/repositories_controller_patch.rb: #unloadable

I dont really think, preventing unloading patches makes a difference. But you could give it a try

Am 18.02.2022 um 17:03 schrieb Jan Catrysse @.***>:

I seem to have the same issue on « production » however on « test » this is working fine (though, I only get the email body, not the headers and attachments). Adding the « unsafe » parameter in the URL works fine.

— Reply to this email directly, view it on GitHub https://github.com/HugoHasenbein/redmine_more_previews/issues/28#issuecomment-1044756386, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJWRDRCIURJU22P3KGQXS5TU3ZUUXANCNFSM5AZNK3GQ. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you commented.

jcatrysse commented 2 years ago

Thank you. This did not change the behavior, I am afraid. The mails are sometimes encoded into windows-1258 or windows-1252, maybe that can be an issue.

Both servers (test/dev and production) have identical config (as far as I can think of)

In production it only works with the unsafe=1 parameter.

afbeelding

But in test and production, I only get half of the beauty.

afbeelding

HugoHasenbein commented 2 years ago

this behavior only for Cliff? Other previewers work?

Am 18.02.2022 um 18:33 schrieb Jan Catrysse @.***>:

Thank you. This did not change the behavior, I am afraid. The mails are sometimes encoded into windows-1258 or windows-1252, maybe that can be an issue.

In production it only works with the unsafe=1 parameter.

https://user-images.githubusercontent.com/23419642/154732702-8a08826e-07b6-4fd5-bcd0-6ee3181d0f3f.png But in test and production, I only get half of the beauty.

https://user-images.githubusercontent.com/23419642/154733236-d563ab30-b8a2-494c-bf15-cb7da4e61d15.png — Reply to this email directly, view it on GitHub https://github.com/HugoHasenbein/redmine_more_previews/issues/28#issuecomment-1044887200, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJWRDRF7LX3FINKKKYXBWO3U3Z7GFANCNFSM5AZNK3GQ. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you commented.

jcatrysse commented 2 years ago
  1. For the moment, the LibreOffice conversion is working, without any changes. (except for this https://github.com/HugoHasenbein/redmine_more_previews/issues/37 but I think that is irrelevant for this problem.)
  2. The PDF preview is working as a charm (very nice!)
  3. Zippy:
    1. I needed to add include RedmineMorePreviews::Lib::RmpText to ./converters/zippy/lib/zippy.rb on line 42
    2. I needed to add require 'array' to ./converters/zippy/lib/zippy.rb on line 26
    3. Now it is working to show ZIP files.
    4. Extracting files does not work because of assetpath is undefined in if entry = zip_file.find_entry(assetpath)
  4. Cliff:
    1. I needed to add include RedmineMorePreviews::Lib::RmpText to ./converters/cliff/lib/cliff.rb on line 31
    2. On development and test it works, but without the fancy options (headers, attachments, ...).
    3. On production, it only works with the unsafe=1 parameter, but with all the nice features.
    4. I tested a pure UTF-8 eml, and the behavior is the same.
    5. Pandoc is throwing me an error about: undefined methodidentifier_param'`

Everything is running on two (as far as I can see) identical FreeBSD servers, with identical Ruby and Rails configurations.

jcatrysse commented 2 years ago

Changing ./converters/cliff/lib/cliff.rb like this resolved the strange accent problem on test but not on production :

    unless unsafe
      doc = Nokogiri::HTML( html )
      doc.encoding = 'UTF-8'
      html = sweep( doc ).to_html
    end

I don't get the encoding differences between the two...

HugoHasenbein commented 2 years ago

this change just sets the encoding. it does not encode. try this - it may alleviate the problem.

unless unsafe doc = Nokogiri::HTML( html ) doc.encoding = charset html = sweep( doc ).to_html end

out in the wild the settings of charsets in emails sometimes is a mess, so we would have to guess the charset an encode our self this, again may fail as well as not all windows encodings are transitive

unless unsafe
  html = sweep( Nokogiri::HTML( RmpText.to_utf8(html) ) ).to_html
end

Am 18.02.2022 um 19:30 schrieb Jan Catrysse @.***>:

Changing ./converters/cliff/lib/cliff.rb like this resolved the strange accent problem on test but not on production :

unless unsafe
  doc = Nokogiri::HTML( html )
  doc.encoding = 'UTF-8'
  html = sweep( doc ).to_html
end

I don't get the encoding differences between the two...

— Reply to this email directly, view it on GitHub https://github.com/HugoHasenbein/redmine_more_previews/issues/28#issuecomment-1044974154, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJWRDRBVQS2OWPYD47OHI33U32F3RANCNFSM5AZNK3GQ. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you commented.

HugoHasenbein commented 2 years ago

did you look in config.encoding = "utf-8" # application.rb and in your database.yml production: adapter: your_db host: localhost encoding: utf8 development: adapter: your_db host: localhost encoding: utf8 test: adapter: your_db host: localhost encoding: utf8

Am 18.02.2022 um 19:30 schrieb Jan Catrysse @.***>:

Changing ./converters/cliff/lib/cliff.rb like this resolved the strange accent problem on test but not on production :

unless unsafe
  doc = Nokogiri::HTML( html )
  doc.encoding = 'UTF-8'
  html = sweep( doc ).to_html
end

I don't get the encoding differences between the two...

— Reply to this email directly, view it on GitHub https://github.com/HugoHasenbein/redmine_more_previews/issues/28#issuecomment-1044974154, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJWRDRBVQS2OWPYD47OHI33U32F3RANCNFSM5AZNK3GQ. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you commented.

jcatrysse commented 2 years ago

I will be testing all that next week, but it should he ok, it's a recent install using sql2 and mysql8 on utf8mb. I will also test with a production environment on my test server, just to exclude server differences.

Maybe I'll check also on a classic linux server.

To be continued.

Thank you and have a nice weekend.

jcatrysse commented 2 years ago

did you look in config.encoding = "utf-8" # application.rb

Yes, this is the case.

and in your database.yml production: adapter: your_db host: localhost encoding: utf8 development: adapter: your_db host: localhost encoding: utf8 test: adapter: your_db host: localhost encoding: utf8

I am using utf8mb4, but that seems to be correct for newer installations.

In the meanwhile, I activated a production environment on my test server and the result is identical (internal server error), so I can exclude server differences. It must have something to do with the difference between the development / test and production settings of Redmine.

For the moment, I get the best result (accent conversion on test) with this code (to be tested further):

    # sweep bad stuff from html
    unless unsafe
      doc = Nokogiri::HTML( html, nil, charset )
      doc.encoding = 'UTF-8'
      html = sweep( doc ).to_html
    end

However, when forcing unsafe=1 I again get all the accent problems.

I need to leave now, but my next step is to search for the differences between test / development and production relating to the code page error. Maybe it is just a more stringent error management, I need to check.

It seems there is still some code page concerns in the unsafe=0 flow, I will look at that later.

jcatrysse commented 2 years ago

For the accent problem, I tuned ./converters/cliff/lib/cliff.rb to the code here below. This seems to fix the conversion in the safe and the unsafe mode.

    # get html
    html, charset = html( mail )

    # convert the charset to UTF-8
    doc = Nokogiri::HTML( html, nil, charset )
    doc.encoding = 'UTF-8'

    # sweep bad stuff from html
    unless unsafe
      html = sweep( doc ).to_html
    else
      html = doc.to_html
    end

I was able to work around the Internal server error by forcing the encoding of the filename to UTF-8. This is not a good fix, as it changed the original Redmine code, but it will potentially help to pinpoint the issue.

app/views/layouts/_file.html.erb - .force_encoding('UTF-8')

<div class="attachments">
<p><%= "#{@attachment.description.force_encoding('UTF-8')} - " unless @attachment.description.blank? %>
   <span class="author"><%= link_to_user(@attachment.author) %>, <%= format_time(@attachment.created_on) %></span></p>
</div>

EDIT: forget my above comment... the issue with the Internal server error seems to be related to the caching. With caching enabled, it does not work.

HugoHasenbein commented 2 years ago

Dear Jan,

an html email does or does not have tags in it's header. One of the meta tags defines the charset. Sometimes the charset in the meta tag and the actually used charset differ. If you use unsafe mode, then text is not sweeped and the html is indeed shown in the browser, whereby the browser reads and honors the meta tag. Possibly, the character conversion of the html email creates a BOM at the beginning of the html overriding the charset. The BOM having precedence over charset. All this is done by the browser with unsafe mode. In safe mode, the email is butched. I tried not to butch as 'bad' it like outlook does. The text is converted to utf-8, but the meta tag is left in the header. So in the end there is a header specifying some charset, the text however is utf-8, so the browser tries to interpret utf-8 as the charset in the meta tag.

So, when Nokogiri reads the html , after sweeping the bad stuff, the text should either be re-encoded to charset or, else the meta tag should be swept as well. Another alternative is to set the meta charset to utf-8, which is in the proposal below:

One fix could be in sweep

add to sweep the following lines:

#
# eventually change charset to utf-8
#
xml.xpath("//meta").each do |node|
  node.keys.each do |attribute|
    if attribute =~ /charset/i
      node.attr("charset").value = "UTF-8"
    end
  end
end

just before the last line of sweep, before the terminating 'xml'

If you could send me the offending email, then I could check on my sid

best regards

Stephan

Am 19.02.2022 um 16:16 schrieb Jan Catrysse @.***>:

For the accent problem, I tuned ./converters/cliff/lib/cliff.rb to the code here below. This seems to fix the conversion in the safe and the unsafe mode.

# get html
html, charset = html( mail )

# convert the charset to UTF-8
doc = Nokogiri::HTML( html, nil, charset )
doc.encoding = 'UTF-8'

# sweep bad stuff from html
unless unsafe
  html = sweep( doc ).to_html
else
  html = doc.to_html
end

I was able to work around the Internal server error by forcing the encoding of the filename to UTF-8. This is not a good fix, as it changed the original Redmine code, but it will potentially help to pinpoint the issue.

app/views/layouts/_file.html.erb - .force_encoding('UTF-8')

<%= ***@***.***_encoding('UTF-8')} - " unless @attachment.description.blank? %> <%= ***@***.***) %>, <%= ***@***.***_on) %>

— Reply to this email directly, view it on GitHub https://github.com/HugoHasenbein/redmine_more_previews/issues/28#issuecomment-1046040974, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJWRDRB4OK66R27H3ZS57TLU36X53ANCNFSM5AZNK3GQ. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you commented.

jcatrysse commented 2 years ago

Hello Dr.

Thank you again for your help. I implemented your code but unsuccessfully. I do, however, have some more and important information.

If you remember the difference in behavior between test and production, that was due to the caching not being enabled.

On production, the internal error happens when caching is enabled, and not when caching has been disabled. Likewise, it doesn't happen in the unsafe mode. Maybe unsafe is disabling some caching?

Could this be a hint to a solution?

This is the error in the logs:

Started GET "/attachments/387252?reload=1" for 10.212.134.10 at 2022-02-19 17:31:39 +0100
Processing by AttachmentsController#show as HTML
  Parameters: {"reload"=>"1", "id"=>"387252"}
  Current user: admin (id=1)
  Rendering plugins/redmine_more_previews/app/views/attachments/more_preview.html.erb within layouts/base
  Rendered plugins/redmine_more_previews/converters/cliff/app/views/redmine_more_previews/hooks/_cliff_preview_attachment_contextual.html.erb (1.1ms)
  Rendered plugins/redmine_more_previews/converters/cliff/app/views/redmine_more_previews/hooks/_cliff_preview_attachment_top.html.erb (148.3ms)
  Rendered layouts/_file.html.erb (172.9ms)
  Rendered plugins/redmine_more_previews/app/views/attachments/more_preview.html.erb within layouts/base (173.4ms)
Completed 500 Internal Server Error in 189ms (ActiveRecord: 9.7ms)

ActionView::Template::Error (incompatible character encodings: ASCII-8BIT and UTF-8):
    10: <p><%= "#{@attachment.description} - " unless @attachment.description.blank? %>
    11:    <span class="author"><%= link_to_user(@attachment.author) %>, <%= format_time(@attachment.created_on) %></span></p>
    12: </div>
    13: <div class="filecontent-container">
    14:   <%= yield %>
    15: </div>
    16: 

plugins/redmine_more_previews/app/views/attachments/more_preview.html.erb:54:in `block in _plugins_redmine_more_previews_app_views_attachments_more_preview_html_erb__2872474851497224052_251500'
app/views/layouts/_file.html.erb:13:in `_app_views_layouts__file_html_erb__373267665750349912_251520'
plugins/redmine_more_previews/app/views/attachments/more_preview.html.erb:8:in `_plugins_redmine_more_previews_app_views_attachments_more_preview_html_erb__2872474851497224052_251500'
plugins/redmine_more_previews/lib/redmine_more_previews/patches/attachments_controller_patch.rb:143:in `show_with_more_previews'
lib/redmine/sudo_mode.rb:61:in `sudo_mode'
HugoHasenbein commented 2 years ago

production vs. development caching seems to be far away from incompatible character encodings. do you have an offending email you can share?

Am 19.02.2022 um 17:37 schrieb Jan Catrysse @.***>:

Hello Dr.

Thank you again for your help. I implemented your code but unsuccessfully. I do, however, have some more and important information.

If you remember the difference in behavior between test and production, that was due to the caching not being enabled.

On production, the internal error happens when caching is enabled, and not when caching has been disabled. Likewise, it doesn't happen in the unsafe mode. Maybe unsafe is disabling some caching?

Could this be a hint to a solution?

This is the error in the logs:

Started GET "/attachments/387252?reload=1" for 10.212.134.10 at 2022-02-19 17:31:39 +0100 Processing by AttachmentsController#show as HTML Parameters: {"reload"=>"1", "id"=>"387252"} Current user: admin (id=1) Rendering plugins/redmine_more_previews/app/views/attachments/more_preview.html.erb within layouts/base Rendered plugins/redmine_more_previews/converters/cliff/app/views/redmine_more_previews/hooks/_cliff_preview_attachment_contextual.html.erb (1.1ms) Rendered plugins/redmine_more_previews/converters/cliff/app/views/redmine_more_previews/hooks/_cliff_preview_attachment_top.html.erb (148.3ms) Rendered layouts/_file.html.erb (172.9ms) Rendered plugins/redmine_more_previews/app/views/attachments/more_preview.html.erb within layouts/base (173.4ms) Completed 500 Internal Server Error in 189ms (ActiveRecord: 9.7ms)

ActionView::Template::Error (incompatible character encodings: ASCII-8BIT and UTF-8): 10:

<%= @.} - " unless @attachment.description.blank? %> 11: <%= @.) %>, <%= @.***_on) %>

12:
13:
14: <%= yield %> 15:
16:

plugins/redmine_more_previews/app/views/attachments/more_preview.html.erb:54:in block in _plugins_redmine_more_previews_app_views_attachments_more_preview_html_erb__2872474851497224052_251500' app/views/layouts/_file.html.erb:13:in_app_views_layoutsfile_html_erb373267665750349912_251520' plugins/redmine_more_previews/app/views/attachments/more_preview.html.erb:8:in _plugins_redmine_more_previews_app_views_attachments_more_preview_html_erb__2872474851497224052_251500' plugins/redmine_more_previews/lib/redmine_more_previews/patches/attachments_controller_patch.rb:143:inshow_with_more_previews' lib/redmine/sudo_mode.rb:61:in `sudo_mode' — Reply to this email directly, view it on GitHub https://github.com/HugoHasenbein/redmine_more_previews/issues/28#issuecomment-1046056303, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJWRDRAML6UMVVLHRO7YB4TU37BMLANCNFSM5AZNK3GQ. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you commented.

jcatrysse commented 2 years ago

The patch I attach to this comment seems to resolve the issues for me, but I am quite sure there is another underlying problem I did not find. Maybe this van help another person with the same issue. Thank you for your help Dr. Stephan. corrected_codepage_issues + configurable path.txt

HugoHasenbein commented 2 years ago

you may want to try version 2.0.8

Am 19.02.2022 um 20:42 schrieb Jan Catrysse @.***>:

The patch I attach to this comment seems to resolve the issues for me, but I am quite sure there is another underlying problem I did not find. Maybe this van help another person with the same issue. Thank you for your help Dr. Stephan. corrected_codepage_issues + configurable path.txt https://github.com/HugoHasenbein/redmine_more_previews/files/8102910/corrected_codepage_issues.%2B.configurable.path.txt — Reply to this email directly, view it on GitHub https://github.com/HugoHasenbein/redmine_more_previews/issues/28#issuecomment-1046090566, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJWRDRHF34GRDRB2GUEPPULU37XCJANCNFSM5AZNK3GQ. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you commented.