aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models/incoming_message_spec.rb
Commit message (Collapse)AuthorAgeLines
* Correctly set uuencoded attachment file size2508-hotfix-bad-uudecodeGareth Rees2015-06-04-0/+1
|
* Use Ruby to decode uuencoded attachmentsGareth Rees2015-06-03-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | Ruby can natively decode uuencoded text with String#unpack. [1] This avoids the uuencode program dependency and avoids writing tempfiles. The actual implementation is taken from mail [2]. The UnixToUnix module is not available in our bundled version of mail. This commit includes a spec to illustrate the failure of uuencode(1) to decode the particular attachment in incoming-request-bad-uuencoding-2. email. Parsing with uuencode returns the following error: External Command: Error from command "uudecode -o /dev/stdout /tmp/foiuu20150530-14811-u6j936": uudecode: /tmp/foiuu20150530-14811-u6j936: No `end' line The file _is_ created and appears to be OK, but the exit code is 1. This causes AlaveteliExternalCommand to fail and return nil. See #2508 [3] for the bug report. [1] http://ruby-doc.org/core-1.8.7/String.html#method-i-unpack [2] https://github.com/mikel/mail/blob/bc4c9bb9321e9d36a678692f2f562d3146b63f78/lib/mail/encodings/unix_to_unix.rb#L7 [3] https://github.com/mysociety/alaveteli/issues/2508
* Add spec for simple uuencoded attachmentGareth Rees2015-06-03-0/+14
| | | Inspired by https://github.com/mikel/mail/commit/bc4c9bb9321e9d36a678692f2f562d3146b63f78
* Use mb_chars to prevent slicing multibyte chars under ruby 1.8Louise Crow2015-05-15-0/+12
| | | | | | | | | | mb_chars provides a multibyte-aware wrapper for strings. It should have no effect on ruby 1.9.3 and above. Although ruby 1.8.7 wouldn't raise errors on a badly sliced multibyte string, on upgrading to ruby 1.9.3 and above, string operations such as gsub, match and join may produce ArgumentErrors with the message "invalid byte sequence in UTF-8". Additionally, a database with 'UTF-8' encoding may produce the error "PG::CharacterNotInRepertoire: ERROR: invalid byte sequence for encoding "UTF8""
* Refactor the application of masks and censor rules to messages.Louise Crow2014-12-15-121/+58
| | | | | | | | | | Seems more logical to make this one method that figures out what to do based on file type. Plus, incoming message does so many things, it seemed like having these related methods be separate would make them easier to read and understand. Also, email, mobile and login substitution texts weren't being translated. Finally, I think passing the censor rules and masks as arguments is a first step in some more decoupling of models.
* Allow a message with more than one event to be destroyed.hotfix/0.18.0.2Louise Crow2014-06-06-0/+18
| | | | Fixes #1569
* Make test specific to versions of ruby with String.encodeLouise Crow2014-02-24-4/+6
| | | | The code being tested is specific in that way.
* Merge remote-tracking branch ↵Louise Crow2014-02-24-1/+7
|\ | | | | | | 'opennewzealand_github/feature/encode-utf8-messages' into rails-3-develop
| * Add test for _get_attachment_text_internal with invalid utf-8Rowan Crawford2014-02-23-1/+7
| |
* | Tighten up expectation, make expected files consistent.Louise Crow2014-01-17-2/+2
|/ | | | | | | Just expecting the parsed file to include the expected one would mean success in the case where nothing has been folded. Tighten up the expectation, and add quoting placeholders to expected files that didn't have them.
* Don't index hidden and requester_only incoming messages.Louise Crow2013-09-16-0/+23
|
* Adding prominence_reason to IncomingMessage.Louise Crow2013-09-16-0/+1
|
* Refactor common logic about prominence and access.Louise Crow2013-09-16-1/+1
| | | | Move it into the Ability module.
* Add a method to ask whether a user can view an incoming message.Louise Crow2013-09-16-0/+57
|
* Add response_event helperLouise Crow2013-09-16-0/+12
| | | | | Add a convenience method for getting the 'response' event associated with an incoming message.
* Add prominence to incoming message.Louise Crow2013-09-16-0/+21
|
* Re-annotate models with database fieldsLouise Crow2013-09-16-0/+20
|
* Prevent erroneous internal error messages with multibyte characters under ↵Louise Crow2013-07-25-1/+12
| | | | ruby 1.8 by using mb_chars for length comparison - it counts multibyte characters.
* Merge branch 'hotfix/0.11.0.14' into rails-3-developLouise Crow2013-06-19-0/+10
|\
| * Allow the HTML display of the body of an email to handle the case where the ↵0.11.0.14hotfix/0.11.0.14Louise Crow2013-06-19-0/+10
| | | | | | | | body is only quoted text and there is no subject.
* | Fix typoLouise Crow2013-06-12-1/+1
| |
* | Make sure raw emails are loaded before running test.Louise Crow2013-06-12-0/+4
|/
* When extracting attachments for an incoming message and getting the body of ↵Louise Crow2013-05-29-0/+43
| | | | the main part in order to look for uuencoded text, make sure that we're getting that main part from the reparsed attachments, and not getting an obsolete attachment. Fixes #958.
* Avoid an FoiAttachment validation failure under Rails 3Mark Longair2013-05-16-0/+11
| | | | | | | | | | | Under Rails 3, the uudecoded FoiAttachment in this test fails validation at the self.save! in IncomingMessage.parse_raw_email, although the FoiAttachment has been correctly created and saved to the database in _uudecode_and_save_attachments. Forcing a reload=true on self.foi_attachments fixes this. Thanks to Louise Crow for finding the fix for this problem.
* Add a new example for unconvertible-to-UTF-8 text part dataMark Longair2013-05-16-2/+9
| | | | | | | | | | | The example file that was used for checking for text attachment data which could not be converted to UTF-8 is one that we *can* actually deal with by guessing the character set, since it's valid GB18030. So, this commit changes that test to check for the first few Chinese characters in that email, and introduces a replacement test with text from /dev/random, which should not be interpretable in any sensible way.
* Reload cached object after extracting attachmentsHenare Degan2013-03-04-0/+1
|
* Rename Configuration class to avoid conflict with ActiveSupport::ConfigurableHenare Degan2013-03-03-1/+1
|
* Merge branch 'rails_xss' into rails-3-spikeMatthew Landauer2013-01-25-0/+7
|\ | | | | | | | | | | | | | | Conflicts: Gemfile Gemfile.lock config/environment.rb lib/i18n_fixes.rb
| * Handle case where info request doesn't have a user_nameLouise Crow2013-01-07-0/+7
| |
* | Merge remote-tracking branch 'mysociety/develop' into rails-3-spikeMatthew Landauer2013-01-04-24/+32
|\| | | | | | | | | | | | | | | | | | | | | Conflicts: Gemfile.lock Rakefile app/controllers/request_controller.rb lib/tasks/rspec.rake spec/controllers/services_controller_spec.rb spec/spec_helper.rb spec/views/request/_after_actions.rhtml_spec.rb
| * Wrap specs on the extraction of RFC-822 headers in code that sets the ENV ↵Louise Crow2012-12-11-24/+32
| | | | | | | | timezone. TMail renders headers using localtime, which is not ideal, but we're migrating away from it anyway, so I'm not sure it's worth delving into the internals of TMail to fix it.
* | Update to new RSpec module namesHenare Degan2012-12-12-1/+1
|/
* Convert url in comment to spec.Louise Crow2012-12-06-0/+8
| | | | | | Conflicts: lib/mail_handler/backends/tmail_backend.rb
* Rename _get_attachment_text_internal_one_file to ↵Louise Crow2012-12-06-2/+2
| | | | get_attachment_text_one_file as it is now an externally-accessed method of the mail handler module.
* Move methods for getting the text out of attachments to the mail handler module.Louise Crow2012-12-06-24/+3
|
* Add spec for handling an RFC822 attachment.Louise Crow2012-12-04-0/+18
| | | | | | Conflicts: spec/models/incoming_message_spec.rb
* Add spec for the adding of headers to plain text bodies in attachments.Louise Crow2012-12-04-0/+13
|
* Rewrite and move spec so that it tests the mail handler method.Louise Crow2012-12-04-5/+0
|
* Rewrite spec to reflect delegation of low-level mail methods to mail ↵Louise Crow2012-12-04-23/+14
| | | | handler, use mail handler methods.
* Move TMail extensions to mail handler.Louise Crow2012-11-15-0/+20
|
* Don't load raw emails data in specs that don't use it.Louise Crow2012-11-15-18/+0
|
* Factor out method for getting a mail object from a fixture file.Louise Crow2012-11-15-10/+7
|
* Use mailhandler method in incoming message specs.Louise Crow2012-11-15-10/+5
|
* Convert example in comment to failing spec, update regex to make spec pass - ↵Louise Crow2012-10-18-0/+9
| | | | again the use of converted HTML parts in emails means extra leading spaces.
* Convert request cited in comment to failing spec, update regex to make it ↵Louise Crow2012-10-18-0/+8
| | | | pass (we now use the HTML parts of emails by preference, so there are some leading spaces.)
* In fact, the message in the example URL was not being folded properly ↵Louise Crow2012-10-11-0/+7
| | | | anymore. Add a failing spec using it as an example.
* Convert example url from comment into passing spec.Louise Crow2012-10-11-0/+7
|
* Clean up spec a bit.Louise Crow2012-10-11-8/+1
|
* Add test for handling a multipart mail with a linebreak in the boundary.Louise Crow2012-10-11-0/+8
|
* Remove debug line.Louise Crow2012-10-11-1/+0
|