fix file warnings for specs on linux
when running the test suite in docker, there are several errors present of the form `file: invalid option -- 'r'`. This patchset addresses the problem by using the expaned option names which appears to work on both platforms. Test Plan: - specs pass Jenkins - on docker, specs in assignment_spec.rb do not throw `file: invalid option --'r'` errors nor fail with `unknown mime type unknown/unknown` Change-Id: Id260c886920180bb17a8b8d6c88c9400906b93e0 Reviewed-on: https://gerrit.instructure.com/163204 Tested-by: Jenkins Reviewed-by: Ryan Shaw <ryan@instructure.com> Reviewed-by: Cody Cutrer <cody@instructure.com> Product-Review: Derek Bender <djbender@instructure.com> QA-Review: Derek Bender <djbender@instructure.com>
This commit is contained in:
parent
a8001ceb3e
commit
74d0262fc0
|
@ -22,7 +22,7 @@ class File
|
|||
if file.class == File || file.class == Tempfile
|
||||
unless RUBY_PLATFORM.include? 'mswin32'
|
||||
# INSTRUCTURE: changed to IO.popen to avoid shell injection attacks when paths include user defined content
|
||||
mime = IO.popen(['file', '--mime', '-br', '--', file.path], &:read).strip
|
||||
mime = IO.popen(['file', '--mime', '--brief', '--raw', '--', file.path], &:read).strip
|
||||
else
|
||||
mime = extensions[File.extname(file.path).gsub('.','').downcase] rescue nil
|
||||
end
|
||||
|
@ -34,7 +34,7 @@ class File
|
|||
temp.close
|
||||
# INSTRUCTURE: changed to IO.popen to be sane and consistent. This one shouldn't be able to contain a user
|
||||
# specified path, but that's no reason to not do things the right way.
|
||||
mime = IO.popen(['file', '--mime', '-br', '--', temp.path], &:read).strip
|
||||
mime = IO.popen(['file', '--mime', '--brief', '--raw', '--', temp.path], &:read).strip
|
||||
mime = mime.gsub(/^.*: */,"")
|
||||
mime = mime.gsub(/;.*$/,"")
|
||||
mime = mime.gsub(/,.*$/,"")
|
||||
|
|
Loading…
Reference in New Issue