The requested changes are too big and content was truncated. Show full diff
@@ -101,10 +101,15 class Attachment < ActiveRecord::Base | |||
|
101 | 101 | logger.info("Saving attachment '#{self.diskfile}' (#{@temp_file.size} bytes)") |
|
102 | 102 | md5 = Digest::MD5.new |
|
103 | 103 | File.open(diskfile, "wb") do |f| |
|
104 | buffer = "" | |
|
105 | while (buffer = @temp_file.read(8192)) | |
|
106 | f.write(buffer) | |
|
107 |
|
|
|
104 | if @temp_file.respond_to?(:read) | |
|
105 | buffer = "" | |
|
106 | while (buffer = @temp_file.read(8192)) | |
|
107 | f.write(buffer) | |
|
108 | md5.update(buffer) | |
|
109 | end | |
|
110 | else | |
|
111 | f.write(@temp_file) | |
|
112 | md5.update(@temp_file) | |
|
108 | 113 | end |
|
109 | 114 | end |
|
110 | 115 | self.digest = md5.hexdigest |
@@ -15,9 +15,7 | |||
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | require 'vendor/tmail' | |
|
19 | ||
|
20 | class MailHandler | |
|
18 | class MailHandler < ActionMailer::Base | |
|
21 | 19 | include ActionView::Helpers::SanitizeHelper |
|
22 | 20 | include Redmine::I18n |
|
23 | 21 | |
@@ -42,9 +40,8 class MailHandler | |||
|
42 | 40 | |
|
43 | 41 | @@handler_options[:no_permission_check] = (@@handler_options[:no_permission_check].to_s == '1' ? true : false) |
|
44 | 42 | |
|
45 | mail = TMail::Mail.parse(email) | |
|
46 | mail.base64_decode | |
|
47 | new.receive(mail) | |
|
43 | email.force_encoding('ASCII-8BIT') if email.respond_to?(:force_encoding) | |
|
44 | super(email) | |
|
48 | 45 | end |
|
49 | 46 | |
|
50 | 47 | def logger |
@@ -71,7 +68,7 class MailHandler | |||
|
71 | 68 | end |
|
72 | 69 | # Ignore auto generated emails |
|
73 | 70 | self.class.ignored_emails_headers.each do |key, ignored_value| |
|
74 |
value = email.header |
|
|
71 | value = email.header[key] | |
|
75 | 72 | if value && value.to_s.downcase == ignored_value.downcase |
|
76 | 73 | if logger && logger.info |
|
77 | 74 | logger.info "MailHandler: ignoring email with #{key}:#{value} header" |
@@ -118,7 +115,7 class MailHandler | |||
|
118 | 115 | |
|
119 | 116 | private |
|
120 | 117 | |
|
121 | MESSAGE_ID_RE = %r{^<redmine\.([a-z0-9_]+)\-(\d+)\.\d+@} | |
|
118 | MESSAGE_ID_RE = %r{^<?redmine\.([a-z0-9_]+)\-(\d+)\.\d+@} | |
|
122 | 119 | ISSUE_REPLY_SUBJECT_RE = %r{\[[^\]]*#(\d+)\]} |
|
123 | 120 | MESSAGE_REPLY_SUBJECT_RE = %r{\[[^\]]*msg(\d+)\]} |
|
124 | 121 | |
@@ -245,9 +242,10 class MailHandler | |||
|
245 | 242 | if email.attachments && email.attachments.any? |
|
246 | 243 | email.attachments.each do |attachment| |
|
247 | 244 | obj.attachments << Attachment.create(:container => obj, |
|
248 | :file => attachment, | |
|
245 | :file => attachment.decoded, | |
|
246 | :filename => attachment.filename, | |
|
249 | 247 | :author => user, |
|
250 |
:content_type => attachment. |
|
|
248 | :content_type => attachment.mime_type) | |
|
251 | 249 | end |
|
252 | 250 | end |
|
253 | 251 | end |
@@ -295,8 +293,13 class MailHandler | |||
|
295 | 293 | keys.reject! {|k| k.blank?} |
|
296 | 294 | keys.collect! {|k| Regexp.escape(k)} |
|
297 | 295 | format ||= '.+' |
|
298 | text.gsub!(/^(#{keys.join('|')})[ \t]*:[ \t]*(#{format})\s*$/i, '') | |
|
299 | $2 && $2.strip | |
|
296 | keyword = nil | |
|
297 | regexp = /^(#{keys.join('|')})[ \t]*:[ \t]*(#{format})\s*$/i | |
|
298 | if m = text.match(regexp) | |
|
299 | keyword = m[2].strip | |
|
300 | text.gsub!(regexp, '') | |
|
301 | end | |
|
302 | keyword | |
|
300 | 303 | end |
|
301 | 304 | |
|
302 | 305 | def target_project |
@@ -347,20 +350,17 class MailHandler | |||
|
347 | 350 | # If not found (eg. HTML-only email), returns the body with tags removed |
|
348 | 351 | def plain_text_body |
|
349 | 352 | return @plain_text_body unless @plain_text_body.nil? |
|
350 | parts = @email.parts.collect {|c| (c.respond_to?(:parts) && !c.parts.empty?) ? c.parts : c}.flatten | |
|
351 | if parts.empty? | |
|
352 | parts << @email | |
|
353 | end | |
|
354 | plain_text_part = parts.detect {|p| p.content_type == 'text/plain'} | |
|
355 | if plain_text_part.nil? | |
|
356 | # no text/plain part found, assuming html-only email | |
|
357 | # strip html tags and remove doctype directive | |
|
358 | @plain_text_body = strip_tags(@email.body.to_s) | |
|
359 | @plain_text_body.gsub! %r{^<!DOCTYPE .*$}, '' | |
|
360 | else | |
|
361 | @plain_text_body = plain_text_part.body.to_s | |
|
353 | ||
|
354 | part = email.text_part || email.html_part || email | |
|
355 | @plain_text_body = Redmine::CodesetUtil.to_utf8(part.body.decoded, part.charset) | |
|
356 | ||
|
357 | if @plain_text_body.respond_to?(:force_encoding) | |
|
358 | # @plain_text_body = @plain_text_body.force_encoding(@email.charset).encode("UTF-8") | |
|
362 | 359 | end |
|
363 | @plain_text_body.strip! | |
|
360 | ||
|
361 | # strip html tags and remove doctype directive | |
|
362 | @plain_text_body = strip_tags(@plain_text_body.strip) | |
|
363 | @plain_text_body.sub! %r{^<!DOCTYPE .*$}, '' | |
|
364 | 364 | @plain_text_body |
|
365 | 365 | end |
|
366 | 366 | |
@@ -407,9 +407,13 class MailHandler | |||
|
407 | 407 | # Creates a User for the +email+ sender |
|
408 | 408 | # Returns the user or nil if it could not be created |
|
409 | 409 | def create_user_from_email |
|
410 |
|
|
|
411 | if addr && !addr.spec.blank? | |
|
412 | user = self.class.new_user_from_attributes(addr.spec, TMail::Unquoter.unquote_and_convert_to(addr.name, 'utf-8')) | |
|
410 | from = email.header['from'].to_s | |
|
411 | addr, name = from, nil | |
|
412 | if m = from.match(/^"?(.+?)"?\s+<(.+@.+)>$/) | |
|
413 | addr, name = m[2], m[1] | |
|
414 | end | |
|
415 | if addr.present? | |
|
416 | user = self.class.new_user_from_attributes(addr, name) | |
|
413 | 417 | if user.save |
|
414 | 418 | user |
|
415 | 419 | else |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed | |
This diff has been collapsed as it changes many lines, (590 lines changed) Show them Hide them |
|
1 | NO CONTENT: file was removed | |
This diff has been collapsed as it changes many lines, (962 lines changed) Show them Hide them |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed | |
This diff has been collapsed as it changes many lines, (1162 lines changed) Show them Hide them |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed | |
This diff has been collapsed as it changes many lines, (578 lines changed) Show them Hide them |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed | |
This diff has been collapsed as it changes many lines, (1060 lines changed) Show them Hide them |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed | |
This diff has been collapsed as it changes many lines, (504 lines changed) Show them Hide them |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed | |
This diff has been collapsed as it changes many lines, (927 lines changed) Show them Hide them |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed | |
This diff has been collapsed as it changes many lines, (596 lines changed) Show them Hide them |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
|
1 | NO CONTENT: file was removed | |
The requested commit or file is too big and content was truncated. Show full diff |
General Comments 0
You need to be logged in to leave comments.
Login now