diff options
author | James McKinney <james@slashpoundbang.com> | 2012-08-23 10:43:49 -0400 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2012-11-01 16:27:38 +0000 |
commit | 121dd9cc01c94dd2a75810b6cd52c8fbf208b6da (patch) | |
tree | 10d4a2dceec7246fa5b160846a22315ebc68bafe | |
parent | b63a205faf27559d1d1710c7a3c68468e3d4c017 (diff) |
remove s switch on regular expressions, which turns on SJIS encoding
Conflicts:
app/models/incoming_message.rb
-rw-r--r-- | app/models/incoming_message.rb | 21 | ||||
-rw-r--r-- | app/models/outgoing_message.rb | 2 |
2 files changed, 12 insertions, 11 deletions
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb index 48fbfe73a..f7c01a209 100644 --- a/app/models/incoming_message.rb +++ b/app/models/incoming_message.rb @@ -1,3 +1,5 @@ +# coding: utf-8 + # == Schema Information # Schema version: 114 # @@ -17,9 +19,6 @@ # last_parsed :datetime # mail_from :text # sent_at :datetime -# - -# encoding: UTF-8 # models/incoming_message.rb: # An (email) message from really anybody to be logged with a request. e.g. A @@ -78,7 +77,7 @@ class IncomingMessage < ActiveRecord::Base # Hack round bug in TMail's MIME decoding. # Report of TMail bug: # http://rubyforge.org/tracker/index.php?func=detail&aid=21810&group_id=4512&atid=17370 - copy_of_raw_data = self.raw_email.data.gsub(/; boundary=\s+"/ims,'; boundary="') + copy_of_raw_data = self.raw_email.data.gsub(/; boundary=\s+"/im,'; boundary="') @mail = TMail::Mail.parse(copy_of_raw_data) @mail.base64_decode @@ -344,13 +343,15 @@ class IncomingMessage < ActiveRecord::Base name = Regexp.escape(self.info_request.user_name) # To end of message sections - text.gsub!(/^\s?#{name}[^\n]+\n([^\n]+\n)?\s?Sent by:[^\n]+\n.*/ims, "\n\n" + replacement) + text.gsub!(/^\s?#{name}[^\n]+\n([^\n]+\n)?\s?Sent by:[^\n]+\n.*/im, "\n\n" + replacement) # Some other sort of forwarding quoting - text.gsub!(/^\s?#{name}\s+To\s+FOI requests at.*/ims, "\n\n" + replacement) + text.gsub!(/^\s?#{name}\s+To\s+FOI requests at.*/im, "\n\n" + replacement) + # http://www.whatdotheyknow.com/request/229/response/809 - text.gsub!(/^\s?From: [^\n]+\n\s?Sent: [^\n]+\n\s?To:\s+['"]?#{name}['"]?\n\s?Subject:.*/ims, "\n\n" + replacement) + text.gsub!(/^\s?From: [^\n]+\n\s?Sent: [^\n]+\n\s?To:\s+['"]?#{name}['"]?\n\s?Subject:.*/im, "\n\n" + replacement) + return text @@ -393,7 +394,7 @@ class IncomingMessage < ActiveRecord::Base # http://www.whatdotheyknow.com/request/police_powers_to_inform_car_insu # http://www.whatdotheyknow.com/request/secured_convictions_aided_by_cct multiline_original_message = '(' + '''>>>.* \d\d/\d\d/\d\d\d\d\s+\d\d:\d\d(?::\d\d)?\s*>>>''' + ')' - text.gsub!(/^(#{multiline_original_message}\n.*)$/ms, replacement) + text.gsub!(/^(#{multiline_original_message}\n.*)$/m, replacement) # Single line sections text.gsub!(/^(>.*\n)/, replacement) @@ -564,7 +565,7 @@ class IncomingMessage < ActiveRecord::Base 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(" ") + text = text.split(/^begin.+^`\n^end\n/m).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" @@ -703,7 +704,7 @@ class IncomingMessage < ActiveRecord::Base # Returns attachments that are uuencoded in main body part def _uudecode_and_save_attachments(text) # Find any uudecoded things buried in it, yeuchly - uus = text.scan(/^begin.+^`\n^end\n/sm) + uus = text.scan(/^begin.+^`\n^end\n/m) attachments = [] for uu in uus # Decode the string diff --git a/app/models/outgoing_message.rb b/app/models/outgoing_message.rb index 0e547d493..2e98e1021 100644 --- a/app/models/outgoing_message.rb +++ b/app/models/outgoing_message.rb @@ -151,7 +151,7 @@ class OutgoingMessage < ActiveRecord::Base raise "Message id #{self.id} has type '#{self.message_type}' which validate can't handle" end end - if self.body =~ /#{get_signoff}\s*\Z/ms + if self.body =~ /#{get_signoff}\s*\Z/m errors.add(:body, _("Please sign at the bottom with your name, or alter the \"%{signoff}\" signature" % { :signoff => get_signoff })) end if !MySociety::Validate.uses_mixed_capitals(self.body) |