aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/track_controller.rb3
-rw-r--r--doc/CHANGES.md1
-rw-r--r--doc/INSTALL-exim4.md11
-rw-r--r--lib/mail_handler/backends/mail_extensions.rb16
-rw-r--r--spec/controllers/track_controller_spec.rb12
5 files changed, 38 insertions, 5 deletions
diff --git a/app/controllers/track_controller.rb b/app/controllers/track_controller.rb
index 40e82e7a4..40fa69290 100644
--- a/app/controllers/track_controller.rb
+++ b/app/controllers/track_controller.rb
@@ -153,6 +153,9 @@ class TrackController < ApplicationController
def atom_feed_internal
@xapian_object = perform_search([InfoRequestEvent], @track_thing.track_query, @track_thing.params[:feed_sortby], nil, 25, 1)
+ # We're assuming that a request to a feed url with no format suffix wants atom/xml
+ # so set that as the default, regardless of content negotiation
+ request.format = 'xml' unless params[:format]
respond_to do |format|
format.json { render :json => @xapian_object.results.map { |r| r[:model].json_for_api(true,
lambda { |t| view_context.highlight_and_excerpt(t, @xapian_object.words_to_highlight, 150) }
diff --git a/doc/CHANGES.md b/doc/CHANGES.md
index 156c4d0dc..e53dcfe0b 100644
--- a/doc/CHANGES.md
+++ b/doc/CHANGES.md
@@ -6,6 +6,7 @@
* Manually remove vendor/rails-locales
* Themes created for 0.9 and below should be updated to work with Rails 3. See `THEMES-UPGRADE.md` for notes on upgrading your theme. You will need to manually remove your old theme directory before running `rails-post-deploy`.
* The `config/httpd.conf` has moved to `config/httpd.conf`, as it may need customization before deploying. It also has a new line setting RackEnv to production - copy this to your config/httpd.conf file.
+* Alaveteli now uses the [mail gem](https://github.com/mikel/mail) rather than [tmail](https://github.com/mikel/tmail) to handle mail. If you're using Exim as your MTA, you'll need to use the setting `extract_addresses_remove_arguments = false` in your Exim conf (see INSTALL-exim4.md for details). This means it won't remove addresses specified with -t on command line from the mail recipient list.
# Version 0.9
## Highlighted features
diff --git a/doc/INSTALL-exim4.md b/doc/INSTALL-exim4.md
index e37da14ff..cdc33ab12 100644
--- a/doc/INSTALL-exim4.md
+++ b/doc/INSTALL-exim4.md
@@ -6,15 +6,16 @@ In `/etc/exim4/conf.d/main/04_alaveteli_options`:
ALAVETELI_HOME=/path/to/alaveteli/software
ALAVETELI_USER=www-data
log_file_path=/var/log/exim4/exim-%slog-%D
- MAIN_LOG_SELECTOR==+all -retry_defer
+ MAIN_LOG_SELECTOR==+all -retry_defer
+ extract_addresses_remove_arguments=false
(The user ALAVETELI_USER should have write permissions on ALAVETELI_HOME).
-Note that the name and location of the log files created by Exim must match
+Note that the name and location of the log files created by Exim must match
what the `load-mail-server-logs` script expects, hence the need for the extra
`log_file_path` setting. And the `check-recent-requests-sent` scripts expects
-the logs to contain the `from=<...>` envelope information, so we make the
-logs more verbose with `log_selector`.
+the logs to contain the `from=<...>` envelope information, so we make the
+logs more verbose with `log_selector`.
In `/etc/exim4/conf.d/router/04_alaveteli`:
@@ -33,7 +34,7 @@ In `/etc/exim4/conf.d/transport/04_alaveteli`:
home_directory = ALAVETELI_HOME
user = ALAVETELI_USER
group = ALAVETELI_USER
-
+
And, assuming you set `INCOMING_EMAIL_PREFIX` in your config at
`config/general` to "foi+", create `config/aliases` with the following
content:
diff --git a/lib/mail_handler/backends/mail_extensions.rb b/lib/mail_handler/backends/mail_extensions.rb
index 54599639b..322c49bb5 100644
--- a/lib/mail_handler/backends/mail_extensions.rb
+++ b/lib/mail_handler/backends/mail_extensions.rb
@@ -112,4 +112,20 @@ module Mail
end
end
end
+ class Ruby19
+
+ def Ruby19.q_value_decode(str)
+ match = str.match(/\=\?(.+)?\?[Qq]\?(.+)?\?\=/m)
+ if match
+ encoding = match[1]
+ str = Encodings::QuotedPrintable.decode(match[2].gsub(/_/, '=20'))
+ # Backport line from mail 2.5 to strip a trailing = character
+ # Remove trailing = if it exists in a Q encoding
+ str = str.sub(/\=$/, '')
+ str.force_encoding(fix_encoding(encoding))
+ end
+ decoded = str.encode("utf-8", :invalid => :replace, :replace => "")
+ decoded.valid_encoding? ? decoded : decoded.encode("utf-16le", :invalid => :replace, :replace => "").encode("utf-8")
+ end
+ end
end
diff --git a/spec/controllers/track_controller_spec.rb b/spec/controllers/track_controller_spec.rb
index 5a766b1e1..1575bc84e 100644
--- a/spec/controllers/track_controller_spec.rb
+++ b/spec/controllers/track_controller_spec.rb
@@ -159,6 +159,18 @@ describe TrackController, "when viewing RSS feed for a track" do
get :track_user, :feed => 'feed', :url_name => "there_is_no_such_user"
}.should raise_error(ActiveRecord::RecordNotFound)
end
+
+ it 'should return atom/xml for a feed url without format specified, even if the
+ requester prefers json' do
+
+ request.env['HTTP_ACCEPT'] = 'application/json,text/xml'
+ track_thing = track_things(:track_fancy_dog_request)
+
+ get :track_request, :feed => 'feed', :url_title => track_thing.info_request.url_title
+ response.should render_template('track/atom_feed')
+ response.content_type.should == 'application/atom+xml'
+ end
+
end
describe TrackController, "when viewing JSON version of a track feed" do