Permalink
Browse files

Fix some file signatures, add some more tests

  • Loading branch information...
distler committed Aug 9, 2012
1 parent b4fe65e commit d956d746cb898ea82572d2e3c8b1b5f45ff54b76
View
@@ -39,30 +39,33 @@ class IO
[0x01,0xDA].pack('c*') => :iris_rgb,
[0xF1,0x00,0x40,0xBB].pack('c*') => :itc,
[0xFF,0xD8,0xFF].pack('c*') => :jpeg,
+ [0x00,0x00,0x00,0x0C,0x6A,0x50,0x20,0x20,0x0D,0x0A].pack('c*') => :jpeg2000,
"IIN1" => :niff,
"MThd" => :midi,
"%PDF" => :pdf,
"VIEW" => :pm,
[0x89].pack('c*') + "PNG" + [0x0D,0x0A,0x1A,0x0A].pack('c*') => :png,
"%!PS-Adobe-" => :postscript,
"Y" + [0xA6].pack('c*') + "j" + [0x95].pack('c*') => :sun_rasterfile,
- "MM*" + [0x00].pack('c*') => :tiff,
+ "MM" + [0x00,0x2A].pack('c*') => :tiff,
+ "MM" + [0x00,0x2B].pack('c*') => :tiff,
"II*" + [0x00].pack('c*') => :tiff,
+ "II+" + [0x00].pack('c*') => :tiff,
"gimp xcf" => :gimp_xcf,
"#FIG" => :xfig,
"/* XPM */" => :xpm,
[0x23,0x21].pack('c*') => :shebang,
[0x1F,0x9D].pack('c*') => :compress,
[0x1F,0x8B,0x08].pack('c*') => :gzip,
"PK" + [0x03,0x04].pack('c*') => :pkzip,
- "Rar" + [0x20,0x1A,0x07,0x00].pack('c*') => :rar,
+ "Rar!" + [0x1A,0x07,0x00].pack('c*') => :rar,
[0x1A,0x45,0xDF,0xA3].pack('c*') => :webm,
[0x4F,0x67,0x67,0x53,0x00].pack('c*') => :ogg,
"fLaC" + [0x00,0x00,0x00,0x22].pack('c*') => :flac,
[0x00,0x00,0x01,0x00].pack('c*') => :ico,
[0x49,0x44,0x33].pack('c*') => :mp3,
"#EXTM3U" => :m3u8,
- ".ELF" => :unix_elf,
+ [0x7F].pack('c*') + "ELF" => :unix_elf,
[0x99,0x00].pack('c*') => :pgp_public_ring,
[0x95,0x01].pack('c*') => :pgp_security_ring,
[0x95,0x00].pack('c*') => :pgp_security_ring,
@@ -87,7 +90,7 @@ class IO
:m4a => 'audio/mp4a-latm',
:aiff => 'audio/x-aiff',
:flac => 'audio/flac',
- :niff => 'application/vnd.music-niff',
+ :niff => 'image/x-niff',
:midi => 'audio/midi',
:fits => 'image/fits',
:gimp_xcf => 'image/xcf',
@@ -110,6 +113,7 @@ class IO
:png => 'image/png',
:gif => 'image/gif',
:jpeg => 'image/jpeg',
+ :jpeg2000 => 'image/jp2',
:sun_rasterfile => 'image/x-cmu-raster',
:postscript => 'application/postscript',
:pdf => 'application/pdf',
@@ -8,6 +8,7 @@
$LOAD_PATH << File.expand_path("#{File.dirname(__FILE__)}/../lib")
+require 'rubygems'
require 'minitest/autorun'
require 'file_signature'
@@ -18,10 +19,14 @@
'sample.gif' => [:gif, 'image/gif'],
'sample.jpg' => [:jpeg, 'image/jpeg'],
'sample.png' => [:png, 'image/png'],
+ 'sample.jp2' => [:jpeg2000, 'image/jp2'],
+ 'sample.webp' => [:webp, 'image/webp'],
+ 'sample.mid' => [:midi, 'audio/midi'],
'sample.ps' => [:postscript, 'application/postscript'],
'sample.ras' => [:sun_rasterfile, 'image/x-cmu-raster'],
'sample.sgi' => [:iris_rgb, 'application/octet-stream'],
'sample.tiff' => [:tiff, 'image/tiff'],
+ 'sample.rar' => [:rar, 'application/x-rar-compressed'],
'sample.xcf.bz2' => [:bzip, 'application/x-bzip'],
'sample.xcf.gz' => [:gzip, 'application/x-gzip'],
'sample.xcf.zip' => [:pkzip, 'application/zip'],
@@ -33,6 +38,7 @@
'sample.m4v' => [:m4v, 'video/x-m4v'],
'sample.mov' => [:quicktime, 'video/quicktime'],
'sample.ogg' => [:ogg, 'application/ogg'],
+ 'sample.spx' => [:ogg, 'application/ogg'],
'sample.webm' => [:webm, 'video/webm'],
'sample.3gp' => [:video_3gpp, 'video/3gpp'],
'sample.3g2' => [:video_3gpp2, 'video/3gpp2'],
@@ -48,6 +54,7 @@
'sample.wav' => [:wave, 'audio/wave'],
'sample.flac' => [:flac, 'audio/flac'],
'sample.aif' => [:aiff, 'audio/x-aiff'],
+ 'sample.elf' => [:unix_elf, 'application/octet-stream'],
}
FILE_TO_MAGIC_NUMBER_MAP.each_pair do |file_name, v|

0 comments on commit d956d74

Please sign in to comment.