OWASP/railsgoat — pull request #123 by raesene (2014-05-22 18:34:02+00:00)
Title: Update benefits.rb accept binary file types.

The modification allows binary file types (e.g. MS word docs) to be uploaded without encountering encoding errors

When uploading with just w+ I was getting an error (below) if I uploaded a binary file type (e.g. PDF, Word)

--
Encoding::UndefinedConversionError in BenefitFormsController#upload

"\xCC" from ASCII-8BIT to UTF-8

Rails.root: /home/railsgoat/railsgoat
Application Trace | Framework Trace | Full Trace

app/models/benefits.rb:8:in `write'
app/models/benefits.rb:8:in `save'
app/controllers/benefit_forms_controller.rb:22:in `upload'
--

Some googling indicated that adding the b parameter to the call to File.open could address this. Tried adding to a local copy and it now seems to take HTML and Word docs fine.