Module: Typor::Magic

Defined in:
lib/typor/magic.rb

Overview

Magic Module

Constant Summary collapse

MAGIC =

Magic

[
	['image/jpeg', [[0, "\377\330\377"], [0, "\377\330"]]],
	['image/png', [[0, "\211PNG"]]],
	['image/gif', [[0, 'GIF8']]],
	['image/tiff', [[0, "MM\000*"], [0, "II*\000"]]],
	['image/bmp', [[0, 'BM', [[14, "\f"], [14, '@'], [14, '(']]]]],
	['image/vnd.adobe.photoshop', []],
	['image/webp', [[0, 'RIFF', [[8, 'WEBP']]]]],
	['image/svg+xml', [[0..256, '<!DOCTYPE svg'], [0..256, '<svg']]],
	['video/x-msvideo', [[0, 'RIFF', [[8, 'AVI ']]], [0, 'AVF0', [[8, 'AVI ']]]]],
	['video/mp4', [[4, 'ftypisom'], [4, 'ftypmp42'], [4, 'ftypMSNV'], [4, 'ftypM4V '], [4, 'ftypf4v ']]],
	['video/quicktime', [[12, 'mdat'], [4, 'mdat'], [4, 'moov'], [4, 'ftypqt']]],
	['video/mpeg', [[0, "G?\377\020"], [0, "\000\000\001\263"], [0, "\000\000\001\272"]]],
	['video/ogg', [[0, 'OggS']]],
	['video/webm', [[0, "\032E\337\243", [[5..65, "B\202", [[8..75, 'webm']]]]]]],
	['video/x-flv', [[0, 'FLV']]],
	['audio/mpeg', [[0, "\377\373"], [0, 'ID3']]],
	['audio/x-wav', [[8, 'WAVE'], [8, 'WAV ']]],
	['audio/aac', [[0, 'ADIF']]],
	['audio/flac', [[0, 'fLaC']]],
	['audio/mp4', [[4, 'ftypM4A']]],
	['audio/ogg', [[0, 'OggS']]],
	['application/pdf', [[0..1024, '%PDF-']]],
	['application/msword', [[0, "1\276\000\000"], [0, 'PO^Q`'], [0, "\3767\000#"], [0, "\333\245-\000\000\000"], [2112, 'MSWordDoc'], [2108, 'MSWordDoc'], [2112, 'Microsoft Word document data'], [546, 'bjbj'], [546, 'jbjb']]],
	['application/vnd.ms-excel', [[2080, 'Microsoft Excel 5.0 Worksheet']]],
	['application/vnd.stardivision.writer', [[2089, 'StarWriter']]],
	['application/x-docbook+xml', [[0, '<?xml', [[0..100, '-//OASIS//DTD DocBook XML'], [0..100, '-//KDE//DTD DocBook XML']]]]],
	['image/x-eps', [[0, '%!', [[15, 'EPS']]], [0, "\004%!", [[16, 'EPS']]], [0, "\305\320\323\306"]]],
	['application/prs.plucker', [[60, 'DataPlkr']]],
	['application/vnd.corel-draw', []],
	['application/x-fictionbook+xml', [[0..256, '<FictionBook']]],
	['application/x-mobipocket-ebook', [[60, 'BOOKMOBI']]],
	['application/x-mozilla-bookmarks', [[0..64, '<!DOCTYPE NETSCAPE-Bookmark-file-1>']]],
	['application/x-nzb', [[0..256, '<nzb']]],
	['application/x-pak', [[0, 'PACK']]],
	['application/x-php', [[0..64, '<?php']]],
	['application/x-xliff', [[0..256, '<xliff']]],
	['application/x-zip-compressed-fb2', [[0, "PK\003\004", [[30..256, '.fb2']]]]],
	['audio/x-flac+ogg', [[0, 'OggS', [[28, 'fLaC']]], [0, 'OggS', [[28, "\177FLAC"]]]]],
	['audio/x-opus+ogg', [[0, 'OggS', [[28, 'OpusHead']]]]],
	['audio/x-speex+ogg', [[0, 'OggS', [[28, 'Speex  ']]]]],
	['audio/x-vorbis+ogg', [[0, 'OggS', [[28, "\001vorbis"]]]]],
	['image/x-kodak-kdc', [[242, 'EASTMAN KODAK COMPANY']]],
	['image/x-niff', [[0, 'IIN1']]],
	['text/x-qml', [[0..256, 'import Qt ']]],
	['video/x-ogm+ogg', [[0, 'OggS', [[29, 'video']]]]],
	['video/x-theora+ogg', [[0, 'OggS', [[28, "\200theora"]]]]],
	['application/atom+xml', [[0..256, '<feed ']]],
	['application/rss+xml', [[0..256, '<rss '], [0..256, '<RSS ']]],
	['application/vnd.apple.mpegurl', [[0, '#EXTM3U', [[0..128, '#EXT-X-TARGETDURATION'], [0..128, '#EXT-X-STREAM-INF']]]]],
	['text/x-opml+xml', [[0..256, '<opml ']]],
	['application/vnd.ms-cab-compressed', [[0, "MSCF\000\000\000\000"]]],
	['application/vnd.ms-wpl', [[0..256, '<?wpl']]],
	['application/x-7z-compressed', [[0, "7z\274\257'\034"]]],
	['application/x-ace', [[7, '**ACE**']]],
	['application/x-arc', []],
	['application/x-cpio', [[0, "\307q"], [0, '070701'], [0, '070702'], [0, "q\307"]]],
	['application/x-font-type1', [[0, 'LWFN'], [65, 'LWFN'], [0, '%!PS-AdobeFont-1.'], [6, '%!PS-AdobeFont-1.'], [0, '%!FontType1-1.'], [6, '%!FontType1-1.']]],
	['application/x-java-pack200', [[0, "\312\376\320\r"]]],
	['application/x-karbon', [[0, "\037\213", [[10, 'KOffice', [[18, "application/x-karbon\004\006"]]]]], [0, "PK\003\004", [[30, 'mimetype', [[38, 'application/x-karbon']]]]]]],
	['application/x-kchart', [[0, "\037\213", [[10, 'KOffice', [[18, "application/x-kchart\004\006"]]]]], [0, "PK\003\004", [[30, 'mimetype', [[38, 'application/x-kchart']]]]]]],
	['application/x-kformula', [[0, "\037\213", [[10, 'KOffice', [[18, "application/x-kformula\004\006"]]]]], [0, "PK\003\004", [[30, 'mimetype', [[38, 'application/x-kformula']]]]]]],
	['application/x-killustrator', [[0, "\037\213", [[10, 'KOffice', [[18, "application/x-killustrator\004\006"]]]]]]],
	['application/x-kivio', [[0, "\037\213", [[10, 'KOffice', [[18, "application/x-kivio\004\006"]]]]], [0, "PK\003\004", [[30, 'mimetype', [[38, 'application/x-kivio']]]]]]],
	['application/x-kontour', [[0, "\037\213", [[10, 'KOffice', [[18, "application/x-kontour\004\006"]]]]], [0, "PK\003\004", [[30, 'mimetype', [[38, 'application/x-kontour']]]]]]],
	['application/x-kpresenter', [[0, "\037\213", [[10, 'KOffice', [[18, "application/x-kpresenter\004\006"]]]]], [0, "PK\003\004", [[30, 'mimetype', [[38, 'application/x-kpresenter']]]]]]],
	['application/x-krita', [[0, "\037\213", [[10, 'KOffice', [[18, "application/x-krita\004\006"]]]]], [0, "PK\003\004", [[30, 'mimetype', [[38, 'application/x-krita']]]]]]],
	['application/x-kspread', [[0, "\037\213", [[10, 'KOffice', [[18, "application/x-kspread\004\006"]]]]], [0, "PK\003\004", [[30, 'mimetype', [[38, 'application/x-kspread']]]]]]],
	['application/x-kword', [[0, "\037\213", [[10, 'KOffice', [[18, "application/x-kword\004\006"]]]]], [0, "PK\003\004", [[30, 'mimetype', [[38, 'application/x-kword']]]]]]],
	['application/x-lha', [[2, '-lh -'], [2, '-lh0-'], [2, '-lh1-'], [2, '-lh2-'], [2, '-lh3-'], [2, '-lh4-'], [2, '-lh5-'], [2, '-lh40-'], [2, '-lhd-'], [2, '-lz4-'], [2, '-lz5-'], [2, '-lzs-']]],
	['application/x-lrzip', [[0, 'LRZI']]],
	['application/x-lz4', [[0, "\004\"M\030"], [0, "\002!L\030"]]],
	['application/x-lzip', [[0, 'LZIP']]],
	['application/x-lzop', [[0, "\211LZO\000\r\n\032\n"]]],
	['application/x-par2', [[0, 'PAR2']]],
	['application/x-qpress', [[0, 'qpress10']]],
	['application/x-quicktime-media-link', [[0, '<?xml', [[0..64, '<?quicktime']]], [0, 'RTSPtext'], [0, 'rtsptext'], [0, 'SMILtext']]],
	['application/x-rar', [[0, 'Rar!']]],
	['application/x-stuffit', [[0, 'StuffIt '], [0, 'SIT!']]],
	['application/x-tar', [[257, "ustar\000"], [257, "ustar  \000"]]],
	['application/x-xar', [[0, 'xar!']]],
	['application/x-xz', [[0, "\3757zXZ\000"]]],
	['application/x-zoo', [[20, "\334\247\304\375"]]],
	['application/xhtml+xml', [[0..256, '//W3C//DTD XHTML '], [0..256, 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'], [0..256, "<html xmlns=\"http://www.w3.org/1999/xhtml"], [0..256, "<HTML xmlns=\"http://www.w3.org/1999/xhtml"]]],
	['audio/vnd.dts.hd', [[0..18725, 'dX %']]],
	['text/x-txt2tags', [[0, '%!postproc'], [0, '%!encoding']]],
	['application/smil+xml', [[0..256, '<smil']]],
	['audio/x-ms-asx', [[0, 'ASF '], [0..64, '<ASX'], [0..64, '<asx'], [0..64, '<Asx']]],
	['application/annodex', [[0, 'OggS', [[28, "fishead\000", [[56..512, "CMML\000\000\000\000"]]]]]]],
	['application/dicom', [[128, 'DICM']]],
	['application/epub+zip', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/epub+zip'], [43, 'application/epub+zip']]]]]]],
	['application/font-woff', [[0, 'wOFF']]],
	['application/gnunet-directory', [[0, "\211GND\r\n\032\n"]]],
	['application/gzip', [[0, "\037\213"]]],
	['application/mac-binhex40', [[11, 'must be converted with BinHex']]],
	['application/mathematica', [[0, '(************** Content-type: application/mathematica'], [100..256, 'This notebook can be used on any computer system with Mathematica'], [10..256, 'This is a Mathematica Notebook file.  It contains ASCII text']]],
	['application/metalink+xml', [[0..256, "<metalink version=\"3.0\""]]],
	['application/metalink4+xml', [[0..256, "<metalink xmlns=\"urn"]]],
	['application/mxf', [[0..256, "\006\016+4\002\005\001\001\r\001\002\001\001\002"]]],
	['application/ogg', [[0, 'OggS']]],
	['application/owl+xml', [[0..256, '<Ontology']]],
	['application/pgp-encrypted', [[0, '-----BEGIN PGP MESSAGE-----']]],
	['application/pgp-keys', [[0, '-----BEGIN PGP PUBLIC KEY BLOCK-----'], [0, '-----BEGIN PGP PRIVATE KEY BLOCK-----'], [0, "\225\001"], [0, "\225\000"], [0, "\231\000"], [0, "\231\001"]]],
	['application/pgp-signature', [[0, '-----BEGIN PGP SIGNATURE-----']]],
	['application/postscript', [[0, "\004%!"], [0, '%!']]],
	['application/rtf', [[0, "{\\rtf"]]],
	['application/sdp', [[0, 'v=', [[0..256, 's=']]]]],
	['application/vnd.adobe.flash.movie', [[0, 'FWS'], [0, 'CWS']]],
	['application/vnd.debian.binary-package', [[0, '!<arch>', [[8, 'debian']]]]],
	['application/vnd.emusic-emusic_package', [[0, 'nF7YLao']]],
	['application/vnd.iccprofile', [[36, 'acsp']]],
	['application/vnd.lotus-1-2-3', [[0, "\000\000\002\000\006\004\006\000\b\000\000\000\000\000"]]],
	['application/vnd.lotus-wordpro', [[0, 'WordPro']]],
	['application/vnd.ms-access', [[0, "\000\001\000\000Standard Jet DB"]]],
	['application/vnd.ms-asf', [[0, "0&\262u"], [0, '[Reference]']]],
	['application/vnd.ms-tnef', [[0, "x\237>\""]]],
	['application/vnd.oasis.opendocument.chart', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.oasis.opendocument.chart']]]]]]],
	['application/vnd.oasis.opendocument.chart-template', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.oasis.opendocument.chart-template']]]]]]],
	['application/vnd.oasis.opendocument.database', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.oasis.opendocument.base']]]]]]],
	['application/vnd.oasis.opendocument.formula', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.oasis.opendocument.formula']]]]]]],
	['application/vnd.oasis.opendocument.formula-template', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.oasis.opendocument.formula-template']]]]]]],
	['application/vnd.oasis.opendocument.graphics', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.oasis.opendocument.graphics']]]]]]],
	['application/vnd.oasis.opendocument.graphics-template', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.oasis.opendocument.graphics-template']]]]]]],
	['application/vnd.oasis.opendocument.image', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.oasis.opendocument.image']]]]]]],
	['application/vnd.oasis.opendocument.presentation', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.oasis.opendocument.presentation']]]]]]],
	['application/vnd.oasis.opendocument.presentation-template', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.oasis.opendocument.presentation-template']]]]]]],
	['application/vnd.oasis.opendocument.spreadsheet', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.oasis.opendocument.spreadsheet']]]]]]],
	['application/vnd.oasis.opendocument.spreadsheet-template', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.oasis.opendocument.spreadsheet-template']]]]]]],
	['application/vnd.oasis.opendocument.text', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.oasis.opendocument.text']]]]]]],
	['application/vnd.oasis.opendocument.text-master', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.oasis.opendocument.text-master']]]]]]],
	['application/vnd.oasis.opendocument.text-template', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.oasis.opendocument.text-template']]]]]]],
	['application/vnd.oasis.opendocument.text-web', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.oasis.opendocument.text-web']]]]]]],
	['application/vnd.rn-realmedia', [[0, '.RMF']]],
	['application/vnd.sun.xml.calc', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.sun.xml.calc']]]]]]],
	['application/vnd.sun.xml.calc.template', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.sun.xml.calc']]]]]]],
	['application/vnd.sun.xml.draw', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.sun.xml.draw']]]]]]],
	['application/vnd.sun.xml.draw.template', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.sun.xml.draw']]]]]]],
	['application/vnd.sun.xml.impress', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.sun.xml.impress']]]]]]],
	['application/vnd.sun.xml.impress.template', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.sun.xml.impress']]]]]]],
	['application/vnd.sun.xml.math', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.sun.xml.math']]]]]]],
	['application/vnd.sun.xml.writer', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.sun.xml.writer']]]]]]],
	['application/vnd.sun.xml.writer.global', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.sun.xml.writer']]]]]]],
	['application/vnd.sun.xml.writer.template', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'application/vnd.sun.xml.writer']]]]]]],
	['application/vnd.symbian.install', [[8, "\031\004\000\020"]]],
	['application/vnd.tcpdump.pcap', [[0, "\324\303\262\241"], [0, "\241\262\303\324"]]],
	['application/vnd.wordperfect', [[1, 'WPC']]],
	['application/vnd.xdgapp', [[0, "xdg-app\000\001\000\211\345"]]],
	['application/winhlp', [[0, "?_\003\000"]]],
	['application/x-abiword', [[0..256, '<abiword'], [0..256, '<!DOCTYPE abiword']]],
	['application/x-alz', [[0, 'ALZ']]],
	['application/x-amiga-disk-format', [[0, "DOS\000"]]],
	['application/x-aportisdoc', [[60, 'TEXtREAd'], [60, 'TEXtTlDc']]],
	['application/x-applix-spreadsheet', [[0, '*BEGIN SPREADSHEETS'], [0, '*BEGIN', [[7, 'SPREADSHEETS']]]]],
	['application/x-applix-word', [[0, '*BEGIN', [[7, 'WORDS']]]]],
	['application/x-arj', [[0, "`\352"]]],
	['application/x-awk', [[0, '#!/bin/gawk'], [0, '#! /bin/gawk'], [0, '#!/usr/bin/gawk'], [0, '#! /usr/bin/gawk'], [0, '#!/usr/local/bin/gawk'], [0, '#! /usr/local/bin/gawk'], [0, '#!/bin/awk'], [0, '#! /bin/awk'], [0, '#!/usr/bin/awk'], [0, '#! /usr/bin/awk']]],
	['application/x-bittorrent', [[0, 'd8:announce']]],
	['application/x-blender', [[0, 'BLENDER']]],
	['application/x-bzip', [[0, 'BZh']]],
	['application/x-ccmx', [[0, 'CCMX']]],
	['application/x-cdrdao-toc', [[0, "CD_ROM\n"], [0, "CD_DA\n"], [0, "CD_ROM_XA\n"], [0, 'CD_TEXT '], [0, "CATALOG \"", [[22, "\""]]]]],
	['application/x-chess-pgn', [[0, '[Event ']]],
	['application/x-cisco-vpn-settings', [[0, '[main]', [[0..256, 'AuthType=']]]]],
	['application/x-compress', [[0, "\037\235"]]],
	['application/x-core', [[0, "\177ELF", [[5, "\001", [[16, "\004\000"]]]]], [0, "\177ELF", [[5, "\002", [[16, "\000\004"]]]]], [0, "Core\001"], [0, "Core\002"]]],
	['application/x-csh', [[2..16, '/bin/tcsh'], [2..16, '/bin/csh'], [2..16, '/bin/env csh'], [2..16, '/bin/env tcsh']]],
	['application/x-dar', [[0, "\000\000\000{"]]],
	['application/x-designer', [[0..256, '<ui '], [0..256, '<UI ']]],
	['application/x-desktop', [[0..32, '[Desktop Entry]'], [0, '[Desktop Action'], [0, '[KDE Desktop Entry]'], [0, '# Config File'], [0, '# KDE Config File']]],
	['application/x-dia-diagram', [[5..100, '<dia:']]],
	['application/x-dia-shape', [[5..100, '<shape']]],
	['application/x-doom-wad', [[0, 'IWAD'], [0, 'PWAD']]],
	['application/x-dvi', [[0, "\367\002"]]],
	['application/x-fluid', [[0, '# data file for the Fltk']]],
	['application/x-font-bdf', [[0, 'STARTFONT ']]],
	['application/x-font-dos', [[0, "\377FON"], [7, "\000EGA"], [7, "\000VID"]]],
	['application/x-font-framemaker', [[0, '<MakerScreenFont']]],
	['application/x-font-libgrx', [[0, "\024\002Y\031"]]],
	['application/x-font-linux-psf', [[0, "6\004"]]],
	['application/x-font-otf', [[0, 'OTTO']]],
	['application/x-font-pcf', [[0, "\001fcp"]]],
	['application/x-font-speedo', [[0, "D1.0\r"]]],
	['application/x-font-sunos-news', [[0, 'StartFont'], [0, "\023z)"], [8, "\023z+"]]],
	['application/x-font-tex', [[0, "\367\203"], [0, "\367Y"], [0, "\367\312"]]],
	['application/x-font-tex-tfm', [[2, "\000\021"], [2, "\000\022"]]],
	['application/x-font-ttf', [[0, 'FFIL'], [65, 'FFIL'], [0, "\000\001\000\000\000"]]],
	['application/x-font-ttx', [[0..256, "<ttFont sfntVersion=\"\\000\\001\\000\\000\" ttLibVersion=\""]]],
	['application/x-font-vfont', [[0, 'FONT']]],
	['application/x-frame', [[0, '<MakerFile'], [0, '<MIFFile'], [0, '<MakerDictionary'], [0, '<MakerScreenFon'], [0, '<MML'], [0, '<Book'], [0, '<Maker']]],
	['application/x-gameboy-rom', [[260, "\316\355ff\314\r\000\v\003s\000\203\000\f\000\r\000\b\021\037\210\211\000\016"]]],
	['application/x-gamecube-rom', [[28, "\3023\237="]]],
	['application/x-gdbm', [[0, "\023W\232\316"], [0, "\316\232W\023"], [0, 'GDBM']]],
	['application/x-gedcom', [[0, '0 HEAD']]],
	['application/x-genesis-rom', [[256, 'SEGA'], [640, 'EAGN'], [640, 'EAMG']]],
	['application/x-gettext-translation', [[0, "\336\022\004\225"], [0, "\225\004\022\336"]]],
	['application/x-glade', [[0..256, '<glade-interface']]],
	['application/x-gnumeric', [[0..64, 'gmr:Workbook'], [0..64, 'gnm:Workbook']]],
	['application/x-go-sgf', [[0, '(;FF[3]'], [0, '(;FF[4]']]],
	['application/x-gtk-builder', [[0..256, '<interface']]],
	['application/x-gtktalog', [[4, 'gtktalog ']]],
	['application/x-hdf', [[0, "\211HDF\r\n\032\n"], [0, "\016\003\023\001"]]],
	['application/x-hwp', [[0, 'HWP Document File']]],
	['application/x-ipod-firmware', [[0, 'S T O P']]],
	['application/x-it87', [[0, 'IT8.7']]],
	['application/x-iwork-keynote-sffkey', [[0, "PK\003\004", [[30, 'index.apxl']]]]],
	['application/x-java', [[0, "\312\376\272\276"]]],
	['application/x-java-jce-keystore', [[0, "\316\316\316\316"]]],
	['application/x-java-jnlp-file', [[0..256, '<jnlp']]],
	['application/x-java-keystore', [[0, "\355\376\355\376"]]],
	['application/x-kspread-crypt', [[0, "\r\032'\002"]]],
	['application/x-ksysv-package', [[4, 'KSysV', [[15, "\001"]]]]],
	['application/x-kword-crypt', [[0, "\r\032'\001"]]],
	['application/x-lyx', [[0, '#LyX']]],
	['application/x-macbinary', [[102, 'mBIN']]],
	['application/x-matroska', [[0, "\032E\337\243", [[5..65, "B\202", [[8..75, 'matroska']]]]]]],
	['application/x-ms-dos-executable', [[0, 'MZ']]],
	['application/x-ms-wim', [[0, "MSWIM\000\000\000"]]],
	['application/x-mswinurl', [[1, 'InternetShortcut'], [1, 'DEFAULT', [[11, 'BASEURL=']]]]],
	['application/x-n64-rom', [[0, "\2007\022@"], [0, "7\200@\022"], [0, "@\0227\200"]]],
	['application/x-nautilus-link', [[0..32, '<nautilus_object nautilus_link']]],
	['application/x-navi-animation', [[0, 'RIFF', [[8, 'ACON']]]]],
	['application/x-netshow-channel', [[0, '[Address]']]],
	['application/x-object', [[0, "\177ELF", [[5, "\001", [[16, "\001\000"]]]]], [0, "\177ELF", [[5, "\002", [[16, "\000\001"]]]]]]],
	['application/x-ole-storage', [[0, "\320\317\021\340\241\261\032\341"], [0, "\320\317\021\340"]]],
	['application/x-oleo', [[31, 'Oleo']]],
	['application/x-pef-executable', [[0, 'Joy!']]],
	['application/x-perl', [[0, "eval \"exec /usr/local/bin/perl"], [2..16, '/bin/perl'], [2..16, '/bin/env perl'], [0..256, 'use strict'], [0..256, 'use warnings'], [0..256, 'use diagnostics'], [0..256, 'use Test::'], [0..256, 'BEGIN {']]],
	['application/x-pocket-word', [[0, "{\\pwi"]]],
	['application/x-python-bytecode', [[0, "\231N\r\n"]]],
	['application/x-qtiplot', [[0, 'QtiPlot']]],
	['application/x-rpm', [[0, "\355\253\356\333"]]],
	['application/x-ruby', [[2..16, '/bin/env ruby'], [2..16, '/bin/ruby']]],
	['application/x-sami', [[0..256, '<SAMI>']]],
	['application/x-saturn-rom', [[0, 'SEGA SEGASATURN'], [16, 'SEGA SEGASATURN']]],
	['application/x-sc', [[38, 'Spreadsheet']]],
	['application/x-sharedlib', [[0, "\177ELF", [[5, "\001", [[16, "\003\000"]]]]], [0, "\177ELF", [[5, "\002", [[16, "\000\003"]]]]], [0, "\203\001"]]],
	['application/x-shellscript', [[10, '# This is a shell archive'], [2..16, '/bin/bash'], [2..16, '/bin/nawk'], [2..16, '/bin/zsh'], [2..16, '/bin/sh'], [2..16, '/bin/ksh'], [2..16, '/bin/dash'], [2..16, '/bin/env sh'], [2..16, '/bin/env bash'], [2..16, '/bin/env zsh'], [2..16, '/bin/env ksh']]],
	['application/x-shorten', [[0, 'ajkg']]],
	['application/x-smaf', [[0, 'MMMD']]],
	['application/x-spss-por', [[40, 'ASCII SPSS PORT FILE']]],
	['application/x-spss-sav', [[0, '$FL2'], [0, '$FL3']]],
	['application/x-sqlite2', [[0, '** This file contains an SQLite']]],
	['application/x-sqlite3', [[0, 'SQLite format 3']]],
	['application/x-subrip', [[0, '1', [[0..256, ' --> ']]]]],
	['application/x-t602', [[0, '@CT 0'], [0, '@CT 1'], [0, '@CT 2']]],
	['application/x-tgif', [[0, '%TGIF']]],
	['application/x-wii-rom', [[24, "]\034\236\243"], [0, 'WBFS'], [0, "WII\001DISC"]]],
	['application/x-wii-wad', [[4, "Is\000\000"], [4, "ib\000\000"], [4, "Bk\000\000"]]],
	['application/x-xbel', [[0..256, '<!DOCTYPE xbel']]],
	['application/x-yaml', [[0, '%YAML']]],
	['application/xslt+xml', [[0..256, '<xsl:stylesheet']]],
	['application/xspf+xml', [[0..64, "<playlist version=\"1"], [0..64, "<playlist version='1"]]],
	['audio/AMR', [[0, "#!AMR\n"], [0, "#!AMR_MC1.0\n"]]],
	['audio/AMR-WB', [[0, "#!AMR-WB\n"], [0, "#!AMR-WB_MC1.0\n"]]],
	['audio/ac3', [[0, "\vw"]]],
	['audio/annodex', [[0, 'OggS', [[28, "fishead\000", [[56..512, "CMML\000\000\000\000"]]]]]]],
	['audio/midi', [[0, 'MThd']]],
	['audio/prs.sid', [[0, 'PSID']]],
	['audio/vnd.dts', [[0, "\177\376\200\001"], [0, "\200\001\177\376"], [0, "\037\377\350\000"], [0, "\350\000\037\377"]]],
	['audio/x-adpcm', [[0, '.snd', [[12, "\000\000\000\027"]]], [0, ".sd\000", [[12, "\001\000\000\000"], [12, "\002\000\000\000"], [12, "\003\000\000\000"], [12, "\004\000\000\000"], [12, "\005\000\000\000"], [12, "\006\000\000\000"], [12, "\a\000\000\000"], [12, "\027\000\000\000"]]]]],
	['audio/x-aifc', [[8, 'AIFC']]],
	['audio/x-aiff', [[8, 'AIFF'], [8, '8SVX']]],
	['audio/x-ape', [[0, 'MAC ']]],
	['audio/x-iriver-pla', [[4, 'iriver UMS PLA']]],
	['audio/x-it', [[0, 'IMPM']]],
	['audio/x-m4b', [[4, 'ftypM4B']]],
	['audio/x-mo3', [[0, 'MO3']]],
	['audio/x-mod', [[0, 'MTM'], [0, 'MMD0'], [0, 'MMD1'], [0, 'if'], [0, 'JN'], [0, 'MAS_UTrack_V00']]],
	['audio/x-mpegurl', [[0, '#EXTM3U']]],
	['audio/x-musepack', [[0, 'MP+']]],
	['audio/x-psf', [[0, 'PSF']]],
	['audio/x-s3m', [[44, 'SCRM']]],
	['audio/x-scpls', [[0, '[playlist]'], [0, '[Playlist]'], [0, '[PLAYLIST]']]],
	['audio/x-speex', [[0, 'Speex']]],
	['audio/x-stm', [[20, "!Scream!\032"], [20, "!SCREAM!\032"], [20, "BMOD2STM\032"]]],
	['audio/x-tta', [[0, 'TTA1']]],
	['audio/x-wavpack', [[0, 'wvpk']]],
	['audio/x-wavpack-correction', [[0, 'wvpk']]],
	['audio/x-xi', [[0, 'Extended Instrument:']]],
	['audio/x-xm', [[0, 'Extended Module:']]],
	['audio/x-xmf', [[0, 'XMF_'], [0, "XMF_2.00\000\000\000\002"]]],
	['image/dpx', [[0, 'SDPX']]],
	['image/fits', [[0, 'SIMPLE  =']]],
	['image/jp2', [[0, "\377O\377Q\000"], [3, "\fjP "], [20, 'jp2']]],
	['image/openraster', [[0, "PK\003\004", [[30, 'mimetype', [[38, 'image/openraster']]]]]]],
	['image/vnd.djvu', [[0, 'AT&TFORM', [[12, 'DJVU']]], [0, 'FORM', [[8, 'DJVU']]]]],
	['image/vnd.djvu+multipage', [[0, 'AT&TFORM', [[12, 'DJVM']]], [0, 'FORM', [[8, 'DJVM']]]]],
	['image/vnd.dxf', [[0..64, "\nHEADER\n"], [0..64, "\r\nHEADER\r\n"]]],
	['image/vnd.microsoft.icon', [[0, "\000\000\001\000", [[5, "\000"]]]]],
	['image/vnd.ms-modi', [[0, "EP*\000"]]],
	['image/vnd.zbrush.pcx', [[0, "\n", [[1, "\000"], [1, "\002"], [1, "\003"], [1, "\005"]]]]],
	['image/x-applix-graphics', [[0, '*BEGIN', [[7, 'GRAPHICS']]]]],
	['image/x-canon-crw', [[0, "II\032\000\000\000HEAPCCDR"]]],
	['image/x-dds', [[0, 'DDS']]],
	['image/x-dib', [[0, "(\000\000\000"]]],
	['image/x-emf', [[0, "\001\000\000\000", [[40, ' EMF', [[44, "\000\000\001\000", [[58, "\000\000"]]]]]]]]],
	['image/x-exr', [[0, "v/1\001"]]],
	['image/x-fpx', [[0, 'FPix']]],
	['image/x-fuji-raf', [[0, 'FUJIFILMCCD-RAW ']]],
	['image/x-icns', [[0, 'icns']]],
	['image/x-ilbm', [[8, 'ILBM'], [8, 'PBM ']]],
	['image/x-minolta-mrw', [[0, "\000MRM"]]],
	['image/x-olympus-orf', [[0, "IIRO\b\000\000\000"]]],
	['image/x-panasonic-raw', [[0, "IIU\000\b\000\000\000"]]],
	['image/x-panasonic-raw2', [[0, "IIU\000\030\000\000\000"]]],
	['image/x-pict', [[522, "\000\021", [[524, "\002\377", [[526, "\f\000", [[528, "\377\376"]]]]]]]]],
	['image/x-pict', [[10, "\000\021", [[12, "\002\377", [[14, "\f\000", [[16, "\377\376"]]]]]]]]],
	['image/x-portable-bitmap', [[0, 'P1', [[2, "\n"], [2, ' '], [2, "\t"], [2, "\r"]]], [0, 'P4', [[2, "\n"], [2, ' '], [2, "\t"], [2, "\r"]]]]],
	['image/x-portable-graymap', [[0, 'P2', [[2, "\n"], [2, ' '], [2, "\t"], [2, "\r"]]], [0, 'P5', [[2, "\n"], [2, ' '], [2, "\t"], [2, "\r"]]]]],
	['image/x-portable-pixmap', [[0, 'P3', [[2, "\n"], [2, ' '], [2, "\t"], [2, "\r"]]], [0, 'P6', [[2, "\n"], [2, ' '], [2, "\t"], [2, "\r"]]]]],
	['image/x-quicktime', [[4, 'idat']]],
	['image/x-sigma-x3f', [[0, 'FOVb']]],
	['image/x-skencil', [[0, '##Sketch']]],
	['image/x-sun-raster', [[0, "Y\246j\225"]]],
	['image/x-tga', [[1, "\000\002", [[16, "\b"], [16, "\020"], [16, "\030"], [16, ' ']]]]],
	['image/x-win-bitmap', [[0, "\000\000\002\000", [[5, "\000"]]]]],
	['image/x-wmf', [[0, "\327\315\306\232", [[22, "\001\000", [[24, "\t\000"]]]]], [0, "\001\000", [[2, "\t\000"]]]]],
	['image/x-xcf', [[0, 'gimp xcf file'], [0, 'gimp xcf v']]],
	['image/x-xcursor', [[0, 'Xcur']]],
	['image/x-xfig', [[0, '#FIG']]],
	['image/x-xpixmap', [[0, '/* XPM']]],
	['message/news', [[0, 'Article'], [0, 'Path:'], [0, 'Xref:']]],
	['message/rfc822', [[0, '#! rnews'], [0, 'Forward to'], [0, 'From:'], [0, 'N#! rnews'], [0, 'Pipe to'], [0, 'Received:'], [0, 'Relay-Version:'], [0, 'Return-Path:'], [0, 'Return-path:'], [0, 'Subject: ']]],
	['text/cache-manifest', [[0, 'CACHE MANIFEST', [[14, ' '], [14, "\t"], [14, "\n"], [14, "\r"]]]]],
	['text/calendar', [[0, 'BEGIN:VCALENDAR'], [0, 'begin:vcalendar']]],
	['text/html', [[0..256, '<!DOCTYPE HTML'], [0..256, '<!doctype html'], [0..256, '<HEAD'], [0..256, '<head'], [0..256, '<TITLE'], [0..256, '<title'], [0..256, '<HTML'], [0..256, '<html'], [0..256, '<SCRIPT'], [0..256, '<script'], [0, '<BODY'], [0, '<body'], [0, '<!--'], [0, '<h1'], [0, '<H1'], [0, '<!doctype HTML'], [0, '<!DOCTYPE html']]],
	['text/plain', [[0, 'This is TeX,'], [0, 'This is METAFONT,']]],
	['text/spreadsheet', [[0, 'ID;']]],
	['text/troff', [[0, ".\\\""], [0, "'\\\""], [0, "'.\\\""], [0, "\\\""]]],
	['text/vcard', [[0, 'BEGIN:VCARD'], [0, 'begin:vcard']]],
	['text/vnd.graphviz', [[0, 'digraph '], [0, 'strict digraph '], [0, 'graph '], [0, 'strict graph ']]],
	['text/vnd.sun.j2me.app-descriptor', [[0, 'MIDlet-']]],
	['text/vnd.trolltech.linguist', [[0..256, '<TS']]],
	['text/vtt', [[0, 'WEBVTT']]],
	['text/x-bibtex', [[0, '% This file was created with JabRef']]],
	['text/x-emacs-lisp', [[0, "\n("], [0, ";ELC\023\000\000\000"]]],
	['text/x-gettext-translation-template', [[0..256, "#, fuzzy\nmsgid \"\"\nmsgstr \"\"\n\"Project-Id-Version:"]]],
	['text/x-google-video-pointer', [[0, '#.download.the.free.Google.Video.Player'], [0, '# download the free Google Video Player']]],
	['text/x-iMelody', [[0, 'BEGIN:IMELODY']]],
	['text/x-iptables', [[0..256, '/etc/sysconfig/iptables'], [0..256, '*filter', [[0..256, ':INPUT', [[0..256, ':FORWARD', [[0..256, ':OUTPUT']]]]]]], [0..256, '-A INPUT', [[0..256, '-A FORWARD', [[0..256, '-A OUTPUT']]]]], [0..256, '-P INPUT', [[0..256, '-P FORWARD', [[0..256, '-P OUTPUT']]]]]]],
	['text/x-ldif', [[0, 'dn: cn='], [0, 'dn: mail=']]],
	['text/x-lua', [[2..16, '/bin/lua'], [2..16, '/bin/luajit'], [2..16, '/bin/env lua'], [2..16, '/bin/env luajit']]],
	['text/x-makefile', [[0, '#!/usr/bin/make'], [0, '#! /usr/bin/make']]],
	['text/x-matlab', [[0, 'function']]],
	['text/x-microdvd', [[0, '{1}'], [0, '{0}'], [0..6, '}{']]],
	['text/x-modelica', [[0, 'class']]],
	['text/x-modelica', [[0, 'record']]],
	['text/x-modelica', [[0, 'model']]],
	['text/x-modelica', [[0, 'function']]],
	['text/x-mpsub', [[0..256, 'FORMAT=']]],
	['text/x-mrml', [[0, '<mrml ']]],
	['text/x-ms-regedit', [[0, 'REGEDIT'], [0, 'Windows Registry Editor Version 5.00'], [0, "\377\376W\000i\000n\000d\000o\000w\000s\000 \000R\000e\000g\000i\000s\000t\000r\000y\000 \000E\000d\000i\000t\000o\000r\000"]]],
	['text/x-mup', [[0, '//!Mup']]],
	['text/x-patch', [[0, "diff\t"], [0, 'diff '], [0, "***\t"], [0, '*** '], [0, '=== '], [0, '--- '], [0, "Only in\t"], [0, 'Only in '], [0, 'Common subdirectories: '], [0, 'Index:']]],
	['text/x-python', [[0, '#!/bin/python'], [0, '#! /bin/python'], [0, "eval \"exec /bin/python"], [0, '#!/usr/bin/python'], [0, '#! /usr/bin/python'], [0, "eval \"exec /usr/bin/python"], [0, '#!/usr/local/bin/python'], [0, '#! /usr/local/bin/python'], [0, "eval \"exec /usr/local/bin/python"], [2..16, '/bin/env python']]],
	['text/x-rpm-spec', [[0, 'Summary: '], [0, '%define ']]],
	['text/x-ssa', [[0..256, '[Script Info]'], [0..256, 'Dialogue: ']]],
	['text/x-subviewer', [[0, '[INFORMATION]']]],
	['text/x-tex', [[1, 'documentclass']]],
	['text/x-uuencode', [[0, 'begin ']]],
	['text/xmcd', [[0, '# xmcd']]],
	['video/3gpp', [[4, 'ftyp3ge'], [4, 'ftyp3gg'], [4, 'ftyp3gp'], [4, 'ftyp3gs']]],
	['video/3gpp2', [[4, 'ftyp3g2']]],
	['video/annodex', [[0, 'OggS', [[28, "fishead\000", [[56..512, "CMML\000\000\000\000"]]]]]]],
	['video/dv', []],
	['video/mp2t', []],
	['video/vnd.mpegurl', [[0, '#EXTM4U']]],
	['video/x-flic', [[0, "\021\257"], [0, "\022\257"]]],
	['video/x-mng', [[0, "\212MNG\r\n\032\n"]]],
	['video/x-nsv', [[0, 'NSVf']]],
	['video/x-sgi-movie', [[0, 'MOVI']]],
	['x-epoc/x-sisx-app', [[0, "z\032 \020"]]],
	['application/x-archive', [[0, '<ar>'], [0, '!<arch>']]],
	['application/x-riff', [[0, 'RIFF']]],
	['application/x-executable', [[0, "\177ELF", [[5, "\001", [[16, "\002\000"]]]]], [0, "\177ELF", [[5, "\002", [[16, "\000\002"]]]]], [0, 'MZ'], [0, "\034R"], [0, "\020\001"], [0, "\021\001"], [0, "\203\001"]]],
	['application/x-iff', [[0, 'FORM']]],
	['application/x-perl', [[0..256, "\n=pod"], [0..256, "\n=head1 NAME"], [0..256, "\n=head1 DESCRIPTION"]]],
	['application/xml', [[0, '<?xml'], [0, '<!--']]],
	['application/zip', [[0, "PK\003\004"]]],
	['audio/basic', [[0, '.snd']]],
	['video/x-javafx', [[0, 'FLV']]],
	['application/x-mobipocket-ebook', [[60, 'TEXtREAd']]],
	['text/x-csrc', [[0, '/*'], [0, '//'], [0, '#include']]],
	['text/x-objcsrc', [[0, '#import']]],
	['application/mbox', [[0, 'From ']]],
	['image/x-tga', [[1, "\001\001"], [1, "\0019"], [1, "\000\003"], [1, "\000\n"], [1, "\000\v"]]],
	['text/x-matlab', [[0, '%']]],
	['text/x-matlab', [[0, '##']]],
	['text/x-modelica', [[0, '//']]],
	['text/x-tex', [[0, '%']]]
]

Class Method Summary collapse

Class Method Details

.check_magic(data, magic) ⇒ Boolean

Check Magic: Determines whether a given chunk of data matches a certain magic array (an array of pattern matchers).

Parameters:

  • data (String)

    A chunk of data to identify

  • magic (Array)

    An array of pattern matchers ([offset/range, value, sub-checks])

Returns:

  • (Boolean)

    True if the data matches the magic, False otherwise



416
417
418
# File 'lib/typor/magic.rb', line 416

def self.check_magic data, magic
	magic.any? { |off, val, sub| ((Range === off) ? (data.slice(off) || '').include?(val) : (data.slice(off, val.size) == val)) && (!sub || check_magic(data, sub)) }
end

.detect_magic(data) ⇒ Array

Detect Magic: Finds a Magic Definition matching data.

Parameters:

  • data (String)

    A chunk of data to identify

Returns:

  • (Array)

    A magic array ([type, magic])



407
408
409
# File 'lib/typor/magic.rb', line 407

def self.detect_magic data
	MAGIC.find { |_type, magic| check_magic data, magic }
end