Defect #18649
closedmail_handler.rb - does not encode non-utf8 characters
0%
Description
Sorry, naive windoze user here, so apologies if i'm breaking some etiquette.
I had a problem where users posting emails to our redmine system that embedded certain unicode characters caused the email system to stall - MySQL squeaked about illegal characters and the script aborted, so no emails processed. To overcome the problem I hacked the code as shown below. This worked for us, but I no very little about ruby or rails or redmine internals so don't know if its a 'good' hack and useful to others.
def self.receive(email, options={}) @@handler_options = options.dup @@handler_options[:issue] ||= {} if @@handler_options[:allow_override].is_a?(String) @@handler_options[:allow_override] = @@handler_options[:allow_override].split(',').collect(&:strip) end @@handler_options[:allow_override] ||= [] # Project needs to be overridable if not specified @@handler_options[:allow_override] << 'project' unless @@handler_options[:issue].has_key?(:project) # Status overridable by default @@handler_options[:allow_override] << 'status' unless @@handler_options[:issue].has_key?(:status) @@handler_options[:no_account_notice] = (@@handler_options[:no_account_notice].to_s == '1') @@handler_options[:no_notification] = (@@handler_options[:no_notification].to_s == '1') @@handler_options[:no_permission_check] = (@@handler_options[:no_permission_check].to_s == '1') email.force_encoding('ASCII-8BIT') if email.respond_to?(:force_encoding) email = email.encode("UTF-8",:invalid=>:replace,:undef=>:replace,:replace=>"?") ##15/12/14 DCN HACK added super(email) end
Environment:
Redmine version 2.5.2.stable
Ruby version 1.9.3-p545 (2014-02-24) [i386-mingw32]
Rails version 3.2.19
Environment production
Database adapter Mysql2
SCM:
Subversion 1.7.2
Git 1.9.4
Filesystem
Redmine plugins:
contracts 1.2.0
redmine_customized_report 0.0.1
redmine_image_clipboard_paste 1.0.0
redmine_impersonate_plugin 0.0.1
redmine_knowledgebase 3.0.4
redmine_silencer 0.4.0
redmine_todos 2.0.5
Related issues
Updated by Toshi MARUYAMA almost 10 years ago
- Status changed from New to Closed
- Resolution set to Duplicate
Duplicate of #16122.
Updated by Toshi MARUYAMA almost 10 years ago
- Is duplicate of Defect #16122: redmine:email:receive should not abort with buggy mail added
Updated by Dave Nichols almost 10 years ago
Its not quite a duplicate of #16122 in that I want the email to be processed by stripping out illegal characters rather than it just being ignored.
Updated by Toshi MARUYAMA almost 10 years ago
Dave Nichols wrote:
Its not quite a duplicate of #16122
But, the reason is same with #16122.
in that I want the email to be processed by stripping out illegal characters rather than it just being ignored.
Your fix in description is wrong.
Mail content is not UTF-8.
For example, source:tags/2.6.0/test/fixtures/mail_handler/japanese_keywords_iso_2022_jp.eml
Updated by Dave Nichols almost 10 years ago
OK. I was just letting others know I had a problem and this was the fix (for me). I thought it may be helpful. If not, fine. However, I would like the email system to absolutely positively not stop, ever, and not ignore things either.