Commit 8339e0fc by Andy Hartford Committed by Tute Costa

Output shorter but still useful error message

Before the error message was sometimes millions of characters long.

> [paperclip] Content Type Spoof: Filename a.csv
> (application/octet-stream from Headers,
> [#<MIME::Type::Columnar:0x007f9f90f89fa8
> @container=#<MIME::Types:0x007f9f90b09d98 ... snip millions of
> characters of output here ...>], @content_type="text/csv",
> @raw_media_type="text", @raw_sub_type="csv", @simplified="text/csv",
> @i18n_key="text.csv", @media_type="text", @sub_type="csv",
> @extensions=["csv"]>] from Extension), content type discovered from
> file command: application/zip. See documentation to allow this
> combination.

Now becomes:

> [paperclip] Content Type Spoof: Filename a.csv
> (application/octet-stream from Headers,
> ["text/comma-separated-values", "text/csv"] from Extension), content
> type discovered from file command: application/zip. See documentation
> to allow this combination.

[fixes #2017]
parent 13ab8ae1
...@@ -12,7 +12,7 @@ module Paperclip ...@@ -12,7 +12,7 @@ module Paperclip
def spoofed? def spoofed?
if has_name? && has_extension? && media_type_mismatch? && mapping_override_mismatch? if has_name? && has_extension? && media_type_mismatch? && mapping_override_mismatch?
Paperclip.log("Content Type Spoof: Filename #{File.basename(@name)} (#{supplied_content_type} from Headers, #{content_types_from_name} from Extension), content type discovered from file command: #{calculated_content_type}. See documentation to allow this combination.") Paperclip.log("Content Type Spoof: Filename #{File.basename(@name)} (#{supplied_content_type} from Headers, #{content_types_from_name.map(&:to_s)} from Extension), content type discovered from file command: #{calculated_content_type}. See documentation to allow this combination.")
true true
else else
false false
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment