Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
paperclip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ikcrm_common
paperclip
Commits
a99ffec8
Commit
a99ffec8
authored
7 years ago
by
Clemens Fuchslocher
Committed by
Sid Raval
7 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MIME type detection of Paperclip::MediaTypeSpoofDetector doesn't work with old versions of file.
Please see #2527 for details.
parent
406ab458
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
1 deletions
+31
-1
lib/paperclip/media_type_spoof_detector.rb
+2
-1
spec/paperclip/file_command_content_type_detector_spec.rb
+14
-0
spec/paperclip/media_type_spoof_detector_spec.rb
+15
-0
No files found.
lib/paperclip/media_type_spoof_detector.rb
View file @
a99ffec8
...
...
@@ -72,7 +72,8 @@ module Paperclip
def
type_from_file_command
begin
Paperclip
.
run
(
"file"
,
"-b --mime :file"
,
:file
=>
@file
.
path
).
split
(
/[:;]\s+/
).
first
Paperclip
.
run
(
"file"
,
"-b --mime :file"
,
file:
@file
.
path
).
split
(
/[:;\s]+/
).
first
rescue
Cocaine
::
CommandLineError
""
end
...
...
This diff is collapsed.
Click to expand it.
spec/paperclip/file_command_content_type_detector_spec.rb
View file @
a99ffec8
...
...
@@ -23,4 +23,18 @@ describe Paperclip::FileCommandContentTypeDetector do
assert_equal
"application/octet-stream"
,
Paperclip
::
FileCommandContentTypeDetector
.
new
(
"windows"
).
detect
end
context
"#type_from_file_command"
do
let
(
:detector
)
{
Paperclip
::
FileCommandContentTypeDetector
.
new
(
"html"
)
}
it
"does work with the output of old versions of file"
do
Paperclip
.
stubs
(
:run
).
returns
(
"text/html charset=us-ascii"
)
expect
(
detector
.
detect
).
to
eq
(
"text/html"
)
end
it
"does work with the output of new versions of file"
do
Paperclip
.
stubs
(
:run
).
returns
(
"text/html; charset=us-ascii"
)
expect
(
detector
.
detect
).
to
eq
(
"text/html"
)
end
end
end
This diff is collapsed.
Click to expand it.
spec/paperclip/media_type_spoof_detector_spec.rb
View file @
a99ffec8
...
...
@@ -76,4 +76,19 @@ describe Paperclip::MediaTypeSpoofDetector do
Paperclip
.
options
[
:content_type_mappings
]
=
{}
end
end
context
"#type_from_file_command"
do
let
(
:file
)
{
File
.
new
(
fixture_file
(
"empty.html"
))
}
let
(
:detector
)
{
Paperclip
::
MediaTypeSpoofDetector
.
new
(
file
,
"html"
,
""
)
}
it
"does work with the output of old versions of file"
do
Paperclip
.
stubs
(
:run
).
returns
(
"text/html charset=us-ascii"
)
expect
(
detector
.
send
(
:type_from_file_command
)).
to
eq
(
"text/html"
)
end
it
"does work with the output of new versions of file"
do
Paperclip
.
stubs
(
:run
).
returns
(
"text/html; charset=us-ascii"
)
expect
(
detector
.
send
(
:type_from_file_command
)).
to
eq
(
"text/html"
)
end
end
end
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment