mysociety / alaveteli

Provide a Freedom of Information request system for your jurisdiction
https://alaveteli.org
Other
385 stars 196 forks source link

[ERROR] admin_request show (ActionView::Template::Error) "string length (137) exceeds the limit 128" #6853

Open gbp opened 2 years ago

gbp commented 2 years ago
An ActionView::Template::Error occurred in admin_request#show:

  string length (137) exceeds the limit 128
  app/models/raw_email.rb:23:in `date'

-------------------------------
Request:
-------------------------------

  * URL        : /en/admin/requests/1
  * HTTP Method: GET
  * Parameters : {"controller"=>"admin_request", "action"=>"show", "id"=>"1", "locale"=>"en"}

-------------------------------
Backtrace:
-------------------------------

  app/models/raw_email.rb:23:in `date'
  app/models/incoming_message.rb:99:in `block in parse_raw_email!'
  app/models/incoming_message.rb:97:in `parse_raw_email!'
  app/models/incoming_message.rb:178:in `mail_from'
  app/views/admin_request/show.html.erb:333
  app/views/admin_request/show.html.erb:330
  app/views/admin_request/show.html.erb:325
gbp commented 2 years ago

This appears to be an issue upstream when parsing emails with the mail gem. Seems to be since Ruby 2.7.5 which included mitigation for CVE-2021-41817.

There is a PR which might fix this issue https://github.com/mikel/mail/pull/1469

gbp commented 2 years ago

For the emails received by AsktheEU they all come from the same domain consilium.europa.eu and is caused by leading spaces on the header rows after the Date header. Such as:

Date: 27 Jan 2022 14:37:56 +0100
 To: ask+request-xxx-xxx@asktheeu.org
 From: "Postmaster Consilium" <xxx@consilium.europa.eu>

As a temporary fix I have corrected the raw emails by removing the spaces for the affect raw emails (IDs: 35358, 35361, 35685, 35766, 35795, 35896, 35952)

gbp commented 2 years ago

Another message has been received with the same issue - manually fixed again.

gbp commented 2 years ago

Created a PR in the AskTheEU theme to save doing this manual fix everytime

gbp commented 2 years ago

Still receiving emails with the same issue. PR is up for review

gbp commented 1 year ago

Seeing the same issue on WDTK now:

Date: 17 Nov 2022 17:57:03 +0000
 To: snip
 From: "Mail Delivery System" <snip>
gbp commented 1 year ago

Seeing this on the Netherlands admin too.