@@ -254,26 +254,9 class MailHandler < ActionMailer::Base | |||||
254 | def add_attachments(obj) |
|
254 | def add_attachments(obj) | |
255 | if email.attachments && email.attachments.any? |
|
255 | if email.attachments && email.attachments.any? | |
256 | email.attachments.each do |attachment| |
|
256 | email.attachments.each do |attachment| | |
257 | filename = attachment.filename |
|
|||
258 | unless filename.respond_to?(:encoding) |
|
|||
259 | # try to reencode to utf8 manually with ruby1.8 |
|
|||
260 | h = attachment.header['Content-Disposition'] |
|
|||
261 | unless h.nil? |
|
|||
262 | begin |
|
|||
263 | if m = h.value.match(/filename\*[0-9\*]*=([^=']+)'/) |
|
|||
264 | filename = Redmine::CodesetUtil.to_utf8(filename, m[1]) |
|
|||
265 | elsif m = h.value.match(/filename=.*=\?([^\?]+)\?[BbQq]\?/) |
|
|||
266 | # http://tools.ietf.org/html/rfc2047#section-4 |
|
|||
267 | filename = Redmine::CodesetUtil.to_utf8(filename, m[1]) |
|
|||
268 | end |
|
|||
269 | rescue |
|
|||
270 | # nop |
|
|||
271 | end |
|
|||
272 | end |
|
|||
273 | end |
|
|||
274 | obj.attachments << Attachment.create(:container => obj, |
|
257 | obj.attachments << Attachment.create(:container => obj, | |
275 | :file => attachment.decoded, |
|
258 | :file => attachment.decoded, | |
276 | :filename => filename, |
|
259 | :filename => attachment.filename, | |
277 | :author => user, |
|
260 | :author => user, | |
278 | :content_type => attachment.mime_type) |
|
261 | :content_type => attachment.mime_type) | |
279 | end |
|
262 | end | |
@@ -396,19 +379,6 class MailHandler < ActionMailer::Base | |||||
396 |
|
379 | |||
397 | def cleaned_up_subject |
|
380 | def cleaned_up_subject | |
398 | subject = email.subject.to_s |
|
381 | subject = email.subject.to_s | |
399 | unless subject.respond_to?(:encoding) |
|
|||
400 | # try to reencode to utf8 manually with ruby1.8 |
|
|||
401 | begin |
|
|||
402 | if h = email.header[:subject] |
|
|||
403 | # http://tools.ietf.org/html/rfc2047#section-4 |
|
|||
404 | if m = h.value.match(/=\?([^\?]+)\?[BbQq]\?/) |
|
|||
405 | subject = Redmine::CodesetUtil.to_utf8(subject, m[1]) |
|
|||
406 | end |
|
|||
407 | end |
|
|||
408 | rescue |
|
|||
409 | # nop |
|
|||
410 | end |
|
|||
411 | end |
|
|||
412 | subject.strip[0,255] |
|
382 | subject.strip[0,255] | |
413 | end |
|
383 | end | |
414 |
|
384 |
General Comments 0
You need to be logged in to leave comments.
Login now