aboutsummaryrefslogtreecommitdiffstats
path: root/spec
Commit message (Collapse)AuthorAgeLines
* Merge branch 'binary-or-utf8-attachment-bodies' into developLouise Crow2015-06-23-25/+144
|\
| * Add body_as_text, default_body.Louise Crow2015-06-22-0/+74
| | | | | | | | | | | | Main intent here is to be more explicit about what form you're getting the attachment body in - valid UTF-8 or binary, and has it been cleaned up in order to be UTF-8?
| * convert_string_to_utf8 returns struct of string and scrubbing status.Louise Crow2015-06-22-8/+15
| |
| * Clearly separate text attachments and binary.Louise Crow2015-06-22-3/+3
| | | | | | | | | | Text type attachments will always have a UTF-8 body (even if it has to be scrubbed).
| * Round trip through utf-16 to clean utf-8 stringLouise Crow2015-06-22-3/+2
| | | | | | | | | | As noted in the ruby docs (http://ruby-doc.org/core-1.9.3/String.html#method-i-encode), any conversion from an encoding to the same encoding is a no-op, covert it first to utf-16.
| * Use ASCII-8BIT for replacement patterns when handling binary data.Louise Crow2015-06-22-13/+52
| | | | | | | | Also be explicit about using UTF-8 when handling text data.
* | Use :platform to add rack-utf8_sanitizerLouise Crow2015-06-19-1/+1
| | | | | | | | | | | | | | Unfortunately, the conditional used in 090531bf2d2b763e5bb281658e91b58905912130 results in `Gemfile.lock` being inconsistent with `Gemfile` under ruby 1.8.7 so we can't use it until after Alaveteli release 0.22, which is the last release that will support ruby 1.8.7.
* | Prevent PublicBody#set_api_key call if unrequiredGareth Rees2015-06-15-1/+37
| | | | | | | | | | Don't call the method unless we need to. Adds #set_api_key! to set a new API key even if there's an existing one.
* | Merge branch 'updating-derived-atts' into developLouise Crow2015-06-12-1/+29
|\ \
| * | Move updating of derived attributes to a concern.Louise Crow2015-06-12-1/+29
| |/ | | | | | | | | | | Add spec to demonstrate that admin-added bodies aren't getting derived attributes. Add a spec to demonstrate the problem setting the first letter for translations. Demonstrate failure to update derived attributes in translations.
* / Use rack-utf8_sanitizer to handle badly-formed UTF-8 in request URI and headers.Louise Crow2015-06-11-0/+24
|/
* Merge branch 'format-admin-form-from-address' into developLouise Crow2015-06-08-0/+18
|\
| * Use address_from_name_and_email to correctly format from field.Louise Crow2015-06-08-0/+18
| | | | | | | | | | | | | | Prior to this, a name with commas in it plus email address would have been treated as several separate addresses, some of which would have just consisted of the bits of the name between the commas, and would have been invalid.
* | Merge branch '2288-public-body-page-performance' into developGareth Rees2015-06-04-2/+2
|\ \
| * | Simplify InfoRequestEvent#is_incoming_message?Gareth Rees2015-06-04-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | Just check if there's an associated InfoRequest. user system total real old 0.010000 0.000000 0.010000 ( 0.012269) new 0.000000 0.000000 0.000000 ( 0.000101)
| * | Speed up PublicBodyHelper#type_of_authorityGareth Rees2015-06-04-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously loaded all PublicBodyHeading and associated PublicBodyCategory records. Now only loads the PublicBodyCategory records that relate to the PublicBody. user system total real old 0.320000 0.000000 0.320000 ( 0.356155) new 0.010000 0.000000 0.010000 ( 0.010077)
* | | Merge branch 'hotfix/0.21.0.36' into developGareth Rees2015-06-04-0/+2914
|\ \ \ | |_|/ |/| |
| * | Correctly set uuencoded attachment file size2508-hotfix-bad-uudecodeGareth Rees2015-06-04-0/+1
| | |
| * | Use Ruby to decode uuencoded attachmentsGareth Rees2015-06-03-0/+2880
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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/+33
| | | | | | | | | Inspired by https://github.com/mikel/mail/commit/bc4c9bb9321e9d36a678692f2f562d3146b63f78
* | | Merge branch 'hotfix/0.21.0.35' into rails-3-developrails-3-developLouise Crow2015-05-29-4/+23
|\| | | |/ |/|
| * Go back to setting up xapian index with fixturesLouise Crow2015-05-29-4/+6
| | | | | | | | | | | | Skipping this seems to have some unexpected interaction with fixture data. https://travis-ci.org/mysociety/alaveteli/jobs/64446161
| * Address#to_s changes the input passed to it - dup before calling.Louise Crow2015-05-28-0/+17
| | | | | | | | Otherwise UTF-8 encoded strings will be returned as ASCII-8BIT.
| * Fix encoding issue with searching for macronsCaleb2015-05-28-0/+11
| | | | | | | | Correct indentation to be consistent
* | Merge branch 'hotfix/0.21.0.33' into rails-3-developLouise Crow2015-05-28-101/+152
|\|
| * Merge branch 'handle-unparsed-email-as-binary' into hotfix/0.21.0.33Louise Crow2015-05-28-30/+43
| |\
| | * Handle unparsed email contents as binary.Louise Crow2015-05-26-11/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I think I was wrong in a83b379fd2d676172855825d0592937b234371e2 in assuming that all email gets properly encoded for transfer. Looking at the mail gem load method https://github.com/mikel/mail/blob/b159e0a542962fdd5e292a48cfffa560d7cf412e/lib/mail/mail.rb#L175a, it reads raw email content from a file in binary mode. So this commit makes both reading and writing the raw_email a binary mode operation and adds a data_as_text method for displaying the data in the admin interface that coerces it to valid utf-8.
| | * Cleanup spec.Louise Crow2015-05-22-13/+14
| | | | | | | | | | | | Move setup to spec - not in common with other specs.
| | * Remove obsolete testLouise Crow2015-05-22-19/+4
| | | | | | | | | | | | | | | We don't write the data for a raw email to the database anymore. It's written to a file.
| * | Add required setupLouise Crow2015-05-28-11/+18
| | |
| * | Make sure spelling corrections are encoded as UTF-8Louise Crow2015-05-28-0/+29
| | |
| * | Cleanup spec.Louise Crow2015-05-26-52/+54
| | | | | | | | | | | | Remove unneeded setup, fixtures are not used in these specs.
| * | Move acts_as_xapian specs to own file.Louise Crow2015-05-26-71/+73
| |/
* | Merge branch 'force-filenames-to-utf8' into rails-3-developLouise Crow2015-05-28-1/+117
|\ \
| * | Fix typoLouise Crow2015-05-15-1/+1
| | |
| * | Force attachment filenames to utf-8 before trying to save themLouise Crow2015-05-15-0/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | In a database with encoding SQL-ASCII, an invalid utf-8 filename can be saved but will cause an "invalid byte sequence in UTF-8" when the filename is prepared for display. In a database with a UTF-8 encoding, saving the string will cause an error like "ActiveRecord::StatementInvalid (PG::Error: ERROR: invalid byte sequence for encoding "UTF8""
| * | Add method for forcing strings to valid utf-8Louise Crow2015-05-14-0/+55
| | | | | | | | | | | | | | | Try likely conversions but if that fails, just replace the characters that are invalid utf-8.
* | | Merge branch 'locale-specific-language-name' into rails-3-developLouise Crow2015-05-28-0/+22
|\ \ \
| * | | Allow locale specific language names and add one for Hong Kong Chinese.Louise Crow2015-05-15-0/+22
| | | |
* | | | Merge remote-tracking branch ↵Louise Crow2015-05-26-1/+2
|\ \ \ \ | | | | | | | | | | | | | | | 'openaustralia_github/286-public-body-show-visible-requests' into rails-3-develop
| * | | | Only include visible requests in count on body pageHenare Degan2015-05-22-1/+2
| | | | | | | | | | | | | | | | | | | | Fixes #286
* | | | | Merge branch 'hotfix/0.21.0.32' into rails-3-developLouise Crow2015-05-26-0/+10
|\ \ \ \ \ | | |_|_|/ | |/| | |
| * | | | Handle invalid 'to' addresses.Louise Crow2015-05-22-0/+10
| | | | |
| * | | | 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""
* | | | | Merge remote-tracking branch 'jpmckinney_github/parentheses' into ↵Louise Crow2015-05-22-74/+74
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | rails-3-develop
| * | | | | Remove all optional parentheses for method calls in RubyJames McKinney2015-05-21-74/+74
| | |_|/ / | |/| | |
* | | | | Merge remote-tracking branch 'jpmckinney_github/okcheck' into rails-3-developLouise Crow2015-05-22-24/+10
|\ \ \ \ \ | |_|_|/ / |/| | | |
| * | | | Simplify HealthCheckable APIJames McKinney2015-05-21-24/+10
| |/ / /
* | | | Add specs for :has_body_as_html?Louise Crow2015-05-22-0/+12
| | | | | | | | | | | | | | | | | | | | Cleaned up by @jpmckinney in 4329ffa27cf83c00e03a0b0600ee54ce06056ee3, so adding a couple of regression specs.
* | | | Cleanup specsLouise Crow2015-05-22-34/+36
|/ / / | | | | | | | | | | | | | | | Don't call load_raw_emails for all specs - only needed for one. Don't call update_display_size! explicitly - the point of the test is that body= should set it as a side effect.