aboutsummaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorFrancis Irving <francis@mysociety.org>2009-12-01 10:39:33 +0000
committerFrancis Irving <francis@mysociety.org>2009-12-01 10:39:33 +0000
commit48dfbbc0d88b504a8eeeaf084e5cf7d24683baef (patch)
treec601f8273154d1555102aac08fb09ebe405dc140 /app/models
parentca9a37e78831d3f277b5006a8265fc8f49fe20d4 (diff)
Strip uudecode parts from main body part before saving to cache, so
cache is shorter. Check that cache is short enough to store well.
Diffstat (limited to 'app/models')
-rw-r--r--app/models/incoming_message.rb16
1 files changed, 10 insertions, 6 deletions
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb
index 90dd08424..3dcbafea9 100644
--- a/app/models/incoming_message.rb
+++ b/app/models/incoming_message.rb
@@ -774,16 +774,20 @@ class IncomingMessage < ActiveRecord::Base
# search results
if self.cached_main_body_text.nil?
text = self.get_main_body_text_internal
+
+ # Strip the uudecode parts from main text
+ # - this also effectively does a .dup as well, so text mods don't alter original
+ text = text.split(/^begin.+^`\n^end\n/sm).join(" ")
+
+ if text.size > 1000000 # 1 MB ish
+ raise "main body text more than 1 MB, need to implement clipping like for attachment text, or there is some other MIME decoding problem or similar"
+ end
+
self.cached_main_body_text = text
self.save!
end
- text = self.cached_main_body_text
-
- # Strip the uudecode parts from main text
- # - this also effectively does a .dup as well, so text mods don't alter original
- text = text.split(/^begin.+^`\n^end\n/sm).join(" ")
- return text
+ return self.cached_main_body_text
end
# Returns body text from main text part of email, converted to UTF-8
def get_main_body_text_internal