magic

package
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 11, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

package magic holds the matching functions used to find MIME types.

Index

Constants

This section is empty.

Variables

View Source
var (
	// SevenZ matches a 7z archive.
	SevenZ = prefix([]byte{0x37, 0x7A, 0xBC, 0xAF, 0x27, 0x1C})
	// Gzip matches gzip files based on http://www.zlib.org/rfc-gzip.html#header-trailer.
	Gzip = prefix([]byte{0x1f, 0x8b})
	// Tar matches a (t)ape (ar)chive file.
	Tar = offset([]byte("ustar"), 257)
	// Fits matches an Flexible Image Transport System file.
	Fits = prefix([]byte{
		0x53, 0x49, 0x4D, 0x50, 0x4C, 0x45, 0x20, 0x20, 0x3D, 0x20,
		0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
		0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x54,
	})
	// Xar matches an eXtensible ARchive format file.
	Xar = prefix([]byte{0x78, 0x61, 0x72, 0x21})
	// Bz2 matches a bzip2 file.
	Bz2 = prefix([]byte{0x42, 0x5A, 0x68})
	// Ar matches an ar (Unix) archive file.
	Ar = prefix([]byte{0x21, 0x3C, 0x61, 0x72, 0x63, 0x68, 0x3E})
	// Deb matches a Debian package file.
	Deb = offset([]byte{
		0x64, 0x65, 0x62, 0x69, 0x61, 0x6E, 0x2D,
		0x62, 0x69, 0x6E, 0x61, 0x72, 0x79,
	}, 8)
	// Warc matches a Web ARChive file.
	Warc = prefix([]byte("WARC/"))
	// Cab matches a Cabinet archive file.
	Cab = prefix([]byte("MSCF"))
	// Xz matches an xz compressed stream based on https://tukaani.org/xz/xz-file-format.txt.
	Xz = prefix([]byte{0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00})
	// Lzip matches an Lzip compressed file.
	Lzip = prefix([]byte{0x4c, 0x5a, 0x49, 0x50})
)
View Source
var (
	// Flac matches a Free Lossless Audio Codec file.
	Flac = prefix([]byte("\x66\x4C\x61\x43\x00\x00\x00\x22"))
	// Midi matches a Musical Instrument Digital Interface file.
	Midi = prefix([]byte("\x4D\x54\x68\x64"))
	// Ape matches a Monkey's Audio file.
	Ape = prefix([]byte("\x4D\x41\x43\x20\x96\x0F\x00\x00\x34\x00\x00\x00\x18\x00\x00\x00\x90\xE3"))
	// MusePack matches a Musepack file.
	MusePack = prefix([]byte("MPCK"))
	// Au matches a Sun Microsystems au file.
	Au = prefix([]byte("\x2E\x73\x6E\x64"))
	// Amr matches an Adaptive Multi-Rate file.
	Amr = prefix([]byte("\x23\x21\x41\x4D\x52"))
	// Voc matches a Creative Voice file.
	Voc = prefix([]byte("Creative Voice File"))
	// M3u matches a Playlist file.
	M3u = prefix([]byte("#EXTM3U"))
)
View Source
var (
	// Lnk matches Microsoft lnk binary format.
	Lnk = prefix([]byte{0x4C, 0x00, 0x00, 0x00, 0x01, 0x14, 0x02, 0x00})
	// Wasm matches a web assembly File Format file.
	Wasm = prefix([]byte{0x00, 0x61, 0x73, 0x6D})
	// Exe matches a Windows/DOS executable file.
	Exe = prefix([]byte{0x4D, 0x5A})
	// Elf matches an Executable and Linkable Format file.
	Elf = prefix([]byte{0x7F, 0x45, 0x4C, 0x46})
	// Nes matches a Nintendo Entertainment system ROM file.
	Nes = prefix([]byte{0x4E, 0x45, 0x53, 0x1A})
	// TzIf matches a Time Zone Information Format (TZif) file.
	TzIf = prefix([]byte("TZif"))
)
View Source
var (
	// Sqlite matches an SQLite database file.
	Sqlite = prefix([]byte{
		0x53, 0x51, 0x4c, 0x69, 0x74, 0x65, 0x20, 0x66,
		0x6f, 0x72, 0x6d, 0x61, 0x74, 0x20, 0x33, 0x00,
	})
	// MsAccessAce matches Microsoft Access dababase file.
	MsAccessAce = offset([]byte("Standard ACE DB"), 4)
	// MsAccessMdb matches legacy Microsoft Access database file (JET, 2003 and earlier).
	MsAccessMdb = offset([]byte("Standard Jet DB"), 4)
)
View Source
var (
	// Pdf matches a Portable Document Format file.
	Pdf = prefix([]byte{0x25, 0x50, 0x44, 0x46})
	// Fdf matches a Forms Data Format file.
	Fdf = prefix([]byte("%FDF"))
	// Mobi matches a Mobi file.
	Mobi = offset([]byte("BOOKMOBI"), 60)
	// Lit matches a Microsoft Lit file.
	Lit = prefix([]byte("ITOLITLS"))
)
View Source
var (
	// Woff matches a Web Open Font Format file.
	Woff = prefix([]byte("wOFF"))
	// Woff2 matches a Web Open Font Format version 2 file.
	Woff2 = prefix([]byte("wOF2"))
	// Otf matches an OpenType font file.
	Otf = prefix([]byte{0x4F, 0x54, 0x54, 0x4F, 0x00})
)
View Source
var (
	// Mp4 matches an MP4 file.
	Mp4 = ftyp(
		[]byte("avc1"), []byte("dash"), []byte("iso2"), []byte("iso3"),
		[]byte("iso4"), []byte("iso5"), []byte("iso6"), []byte("isom"),
		[]byte("mmp4"), []byte("mp41"), []byte("mp42"), []byte("mp4v"),
		[]byte("mp71"), []byte("MSNV"), []byte("NDAS"), []byte("NDSC"),
		[]byte("NSDC"), []byte("NSDH"), []byte("NDSM"), []byte("NDSP"),
		[]byte("NDSS"), []byte("NDXC"), []byte("NDXH"), []byte("NDXM"),
		[]byte("NDXP"), []byte("NDXS"), []byte("F4V "), []byte("F4P "),
	)
	// ThreeGP matches a 3GPP file.
	ThreeGP = ftyp(
		[]byte("3gp1"), []byte("3gp2"), []byte("3gp3"), []byte("3gp4"),
		[]byte("3gp5"), []byte("3gp6"), []byte("3gp7"), []byte("3gs7"),
		[]byte("3ge6"), []byte("3ge7"), []byte("3gg6"),
	)
	// ThreeG2 matches a 3GPP2 file.
	ThreeG2 = ftyp(
		[]byte("3g24"), []byte("3g25"), []byte("3g26"), []byte("3g2a"),
		[]byte("3g2b"), []byte("3g2c"), []byte("KDDI"),
	)
	// AMp4 matches an audio MP4 file.
	AMp4 = ftyp(

		[]byte("F4A "), []byte("F4B "),

		[]byte("M4B "), []byte("M4P "),

		[]byte("MSNV"),

		[]byte("NDAS"),
	)
	// QuickTime matches a QuickTime File Format file.
	QuickTime = ftyp([]byte("qt  "), []byte("moov"))
	// Mqv matches a Sony / Mobile QuickTime  file.
	Mqv = ftyp([]byte("mqt "))
	// M4a matches an audio M4A file.
	M4a = ftyp([]byte("M4A "))
	// M4v matches an Appl4 M4V video file.
	M4v = ftyp([]byte("M4V "), []byte("M4VH"), []byte("M4VP"))
	// Heic matches a High Efficiency Image Coding (HEIC) file.
	Heic = ftyp([]byte("heic"), []byte("heix"))
	// HeicSequence matches a High Efficiency Image Coding (HEIC) file sequence.
	HeicSequence = ftyp([]byte("hevc"), []byte("hevx"))
	// Heif matches a High Efficiency Image File Format (HEIF) file.
	Heif = ftyp([]byte("mif1"), []byte("heim"), []byte("heis"), []byte("avic"))
	// HeifSequence matches a High Efficiency Image File Format (HEIF) file sequence.
	HeifSequence = ftyp([]byte("msf1"), []byte("hevm"), []byte("hevs"), []byte("avcs"))
)
View Source
var (
	// Png matches a Portable Network Graphics file.
	Png = prefix([]byte{0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A})
	// Jpg matches a Joint Photographic Experts Group file.
	Jpg = prefix([]byte{0xFF, 0xD8, 0xFF})
	// Jp2 matches a JPEG 2000 Image file (ISO 15444-1).
	Jp2 = jpeg2k([]byte{0x6a, 0x70, 0x32, 0x20})
	// Jpx matches a JPEG 2000 Image file (ISO 15444-2).
	Jpx = jpeg2k([]byte{0x6a, 0x70, 0x78, 0x20})
	// Jpm matches a JPEG 2000 Image file (ISO 15444-6).
	Jpm = jpeg2k([]byte{0x6a, 0x70, 0x6D, 0x20})
	// Gif matches a Graphics Interchange Format file.
	Gif = prefix([]byte("GIF87a"), []byte("GIF89a"))
	// Bmp matches a bitmap image file.
	Bmp = prefix([]byte{0x42, 0x4D})
	// Ps matches a PostScript file.
	Ps = prefix([]byte("%!PS-Adobe-"))
	// Psd matches a Photoshop Document file.
	Psd = prefix([]byte("8BPS"))
	// Ico matches an ICO file.
	Ico = prefix([]byte{0x00, 0x00, 0x01, 0x00}, []byte{0x00, 0x00, 0x02, 0x00})
	// Icns matches an ICNS (Apple Icon Image format) file.
	Icns = prefix([]byte("icns"))
	// Tiff matches a Tagged Image File Format file.
	Tiff = prefix([]byte{0x49, 0x49, 0x2A, 0x00}, []byte{0x4D, 0x4D, 0x00, 0x2A})
	// Bpg matches a Better Portable Graphics file.
	Bpg = prefix([]byte{0x42, 0x50, 0x47, 0xFB})
	// Xcf matches GIMP image data.
	Xcf = prefix([]byte("gimp xcf"))
	// Pat matches GIMP pattern data.
	Pat = offset([]byte("GPAT"), 20)
	// Gbr matches GIMP brush data.
	Gbr = offset([]byte("GIMP"), 20)
	// Hdr matches Radiance HDR image.
	// https://web.archive.org/web/20060913152809/http://local.wasp.uwa.edu.au/~pbourke/dataformats/pic/
	Hdr = prefix([]byte("#?RADIANCE\n"))
	// Xpm matches X PixMap image data.
	Xpm = prefix([]byte{0x2F, 0x2A, 0x20, 0x58, 0x50, 0x4D, 0x20, 0x2A, 0x2F})
)
View Source
var (
	// Html matches a Hypertext Markup Language file.
	Html = markup(
		[]byte("<!DOCTYPE HTML"),
		[]byte("<HTML"),
		[]byte("<HEAD"),
		[]byte("<SCRIPT"),
		[]byte("<IFRAME"),
		[]byte("<H1"),
		[]byte("<DIV"),
		[]byte("<FONT"),
		[]byte("<TABLE"),
		[]byte("<A"),
		[]byte("<STYLE"),
		[]byte("<TITLE"),
		[]byte("<B"),
		[]byte("<BODY"),
		[]byte("<BR"),
		[]byte("<P"),
		[]byte("<!--"),
	)
	// Xml matches an Extensible Markup Language file.
	Xml = markup([]byte("<?XML"))
	// Owl2 matches an Owl ontology file.
	Owl2 = xml(newXmlSig("Ontology", `xmlns="http://www.w3.org/2002/07/owl#"`))
	// Rss matches a Rich Site Summary file.
	Rss = xml(newXmlSig("rss", ""))
	// Atom matches an Atom Syndication Format file.
	Atom = xml(newXmlSig("feed", `xmlns="http://www.w3.org/2005/Atom"`))
	// Kml matches a Keyhole Markup Language file.
	Kml = xml(
		newXmlSig("kml", `xmlns="http://www.opengis.net/kml/2.2"`),
		newXmlSig("kml", `xmlns="http://earth.google.com/kml/2.0"`),
		newXmlSig("kml", `xmlns="http://earth.google.com/kml/2.1"`),
		newXmlSig("kml", `xmlns="http://earth.google.com/kml/2.2"`),
	)
	// Xliff matches a XML Localization Interchange File Format file.
	Xliff = xml(newXmlSig("xliff", `xmlns="urn:oasis:names:tc:xliff:document:1.2"`))
	// Collada matches a COLLAborative Design Activity file.
	Collada = xml(newXmlSig("COLLADA", `xmlns="http://www.collada.org/2005/11/COLLADASchema"`))
	// Gml matches a Geography Markup Language file.
	Gml = xml(
		newXmlSig("", `xmlns:gml="http://www.opengis.net/gml"`),
		newXmlSig("", `xmlns:gml="http://www.opengis.net/gml/3.2"`),
		newXmlSig("", `xmlns:gml="http://www.opengis.net/gml/3.3/exr"`),
	)
	// Gpx matches a GPS Exchange Format file.
	Gpx = xml(newXmlSig("gpx", `xmlns="http://www.topografix.com/GPX/1/1"`))
	// Tcx matches a Training Center XML file.
	Tcx = xml(newXmlSig("TrainingCenterDatabase", `xmlns="http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2"`))
	// X3d matches an Extensible 3D Graphics file.
	X3d = xml(newXmlSig("X3D", `xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance"`))
	// Amf matches an Additive Manufacturing XML file.
	Amf = xml(newXmlSig("amf", ""))
	// Threemf matches a 3D Manufacturing Format file.
	Threemf = xml(newXmlSig("model", `xmlns="http://schemas.microsoft.com/3dmanufacturing/core/2015/02"`))
	// Xfdf matches a XML Forms Data Format file.
	Xfdf = xml(newXmlSig("xfdf", `xmlns="http://ns.adobe.com/xfdf/"`))
	// VCard matches a Virtual Contact File.
	VCard = ciPrefix([]byte("BEGIN:VCARD\n"), []byte("BEGIN:VCARD\r\n"))
	// ICalendar matches a iCalendar file.
	ICalendar = ciPrefix([]byte("BEGIN:VCALENDAR\n"), []byte("BEGIN:VCALENDAR\r\n"))

	// Js matches a Javascript file.
	Js = shebang(
		[]byte("/bin/node"),
		[]byte("/usr/bin/node"),
		[]byte("/bin/nodejs"),
		[]byte("/usr/bin/nodejs"),
		[]byte("/usr/bin/env node"),
		[]byte("/usr/bin/env nodejs"),
	)
	// Lua matches a Lua programming language file.
	Lua = shebang(
		[]byte("/usr/bin/lua"),
		[]byte("/usr/local/bin/lua"),
		[]byte("/usr/bin/env lua"),
	)
	// Perl matches a Perl programming language file.
	Perl = shebang(
		[]byte("/usr/bin/perl"),
		[]byte("/usr/bin/env perl"),
	)
	// Python matches a Python programming language file.
	Python = shebang(
		[]byte("/usr/bin/python"),
		[]byte("/usr/local/bin/python"),
		[]byte("/usr/bin/env python"),
	)
	// Tcl matches a Tcl programming language file.
	Tcl = shebang(
		[]byte("/usr/bin/tcl"),
		[]byte("/usr/local/bin/tcl"),
		[]byte("/usr/bin/env tcl"),
		[]byte("/usr/bin/tclsh"),
		[]byte("/usr/local/bin/tclsh"),
		[]byte("/usr/bin/env tclsh"),
		[]byte("/usr/bin/wish"),
		[]byte("/usr/local/bin/wish"),
		[]byte("/usr/bin/env wish"),
	)
	// Rtf matches a Rich Text Format file.
	Rtf = prefix([]byte("{\\rtf1"))
)
View Source
var (
	// Flv matches a Flash video file.
	Flv = prefix([]byte("\x46\x4C\x56\x01"))
	// Asf matches an Advanced Systems Format file.
	Asf = prefix([]byte{
		0x30, 0x26, 0xB2, 0x75, 0x8E, 0x66, 0xCF, 0x11,
		0xA6, 0xD9, 0x00, 0xAA, 0x00, 0x62, 0xCE, 0x6C,
	})
	// Rmvb matches a RealMedia Variable Bitrate file.
	Rmvb = prefix([]byte{0x2E, 0x52, 0x4D, 0x46})
)
View Source
var (
	// Odt matches an OpenDocument Text file.
	Odt = offset([]byte("mimetypeapplication/vnd.oasis.opendocument.text"), 30)
	// Ott matches an OpenDocument Text Template file.
	Ott = offset([]byte("mimetypeapplication/vnd.oasis.opendocument.text-template"), 30)
	// Ods matches an OpenDocument Spreadsheet file.
	Ods = offset([]byte("mimetypeapplication/vnd.oasis.opendocument.spreadsheet"), 30)
	// Ots matches an OpenDocument Spreadsheet Template file.
	Ots = offset([]byte("mimetypeapplication/vnd.oasis.opendocument.spreadsheet-template"), 30)
	// Odp matches an OpenDocument Presentation file.
	Odp = offset([]byte("mimetypeapplication/vnd.oasis.opendocument.presentation"), 30)
	// Otp matches an OpenDocument Presentation Template file.
	Otp = offset([]byte("mimetypeapplication/vnd.oasis.opendocument.presentation-template"), 30)
	// Odg matches an OpenDocument Drawing file.
	Odg = offset([]byte("mimetypeapplication/vnd.oasis.opendocument.graphics"), 30)
	// Otg matches an OpenDocument Drawing Template file.
	Otg = offset([]byte("mimetypeapplication/vnd.oasis.opendocument.graphics-template"), 30)
	// Odf matches an OpenDocument Formula file.
	Odf = offset([]byte("mimetypeapplication/vnd.oasis.opendocument.formula"), 30)
	// Odc matches an OpenDocument Chart file.
	Odc = offset([]byte("mimetypeapplication/vnd.oasis.opendocument.chart"), 30)
	// Epub matches an EPUB file.
	Epub = offset([]byte("mimetypeapplication/epub+zip"), 30)
	// Sxc matches an OpenOffice Spreadsheet file.
	Sxc = offset([]byte("mimetypeapplication/vnd.sun.xml.calc"), 30)
)
View Source
var Glb = prefix([]byte("\x67\x6C\x54\x46\x02\x00\x00\x00"),
	[]byte("\x67\x6C\x54\x46\x01\x00\x00\x00"))

Glb matches a glTF model format file. GLB is the binary file format representation of 3D models save in the GL transmission Format (glTF). see more: https://docs.fileformat.com/3d/glb/

https://www.iana.org/assignments/media-types/model/gltf-binary

GLB file format is based on little endian and its header structure show below:

<-- 12-byte header --> | magic | version | length | | (uint32) | (uint32) | (uint32) | | \x67\x6C\x54\x46 | \x01\x00\x00\x00 | ... | | g l T F | 1 | ... |

View Source
var Torrent = prefix([]byte("d8:announce"))

Torrent has bencoded text in the beginning.

Functions

func Aac

func Aac(raw []byte, limit uint32) bool

Aac matches an Advanced Audio Coding file.

func Aaf

func Aaf(raw []byte, limit uint32) bool

Aaf matches an Advanced Authoring Format file. See: https://pyaaf.readthedocs.io/en/latest/about.html See: https://en.wikipedia.org/wiki/Advanced_Authoring_Format

func Aiff

func Aiff(raw []byte, limit uint32) bool

Aiff matches Audio Interchange File Format file.

func Avi

func Avi(raw []byte, limit uint32) bool

Avi matches an Audio Video Interleaved file.

func Class

func Class(raw []byte, limit uint32) bool

Class matches a java class file.

func Cpio

func Cpio(raw []byte, limit uint32) bool

Cpio matches a cpio archive file.

func Crx

func Crx(raw []byte, limit uint32) bool

Crx matches a Chrome extension file: a zip archive prepended by a package header.

func Csv

func Csv(raw []byte, limit uint32) bool

Csv matches a comma-separated values file.

func Dbf

func Dbf(raw []byte, limit uint32) bool

Dbf matches a dBase file. https://www.dbase.com/Knowledgebase/INT/db7_file_fmt.htm

func Dcm

func Dcm(raw []byte, limit uint32) bool

Dcm matches a DICOM medical format file.

func DjVu

func DjVu(raw []byte, limit uint32) bool

DjVu matches a DjVu file.

func Doc

func Doc(raw []byte, limit uint32) bool

Doc matches a Microsoft Word 97-2003 file.

BUG(gabriel-vasile): Doc should look for subheaders like Ppt and Xls does.

Ole is a container for Doc, Ppt, Pub and Xls. Right now, when an Ole file is detected, it is considered to be a Doc file if the checks for Ppt, Pub and Xls failed.

func Docx

func Docx(raw []byte, limit uint32) bool

Docx matches a Microsoft Word 2007 file.

func Dwg

func Dwg(raw []byte, _ uint32) bool

Dwg matches a CAD drawing file.

func ElfDump

func ElfDump(raw []byte, limit uint32) bool

ElfDump matches a core dump file.

func ElfExe

func ElfExe(raw []byte, limit uint32) bool

ElfExe matches an executable file.

func ElfLib

func ElfLib(raw []byte, limit uint32) bool

ElfLib matches a shared library file.

func ElfObj

func ElfObj(raw []byte, limit uint32) bool

ElfObj matches an object file.

func Eot

func Eot(raw []byte, limit uint32) bool

Eot matches an Embedded OpenType font file.

func GeoJSON added in v1.4.0

func GeoJSON(raw []byte, limit uint32) bool

GeoJSON matches a RFC 7946 GeoJSON file.

GeoJSON detection implies searching for key:value pairs like: `"type": "Feature"` in the input. BUG(gabriel-vasile): The "type" key should be searched for in the root object.

func HAR added in v1.4.0

func HAR(raw []byte, limit uint32) bool

Har matches a HAR Spec file. Spec: http://www.softwareishard.com/blog/har-12-spec/

func JSON added in v1.4.0

func JSON(raw []byte, limit uint32) bool

JSON matches a JavaScript Object Notation file.

func Jar

func Jar(raw []byte, limit uint32) bool

Jar matches a Java archive file.

func Jxl added in v1.4.0

func Jxl(raw []byte, _ uint32) bool

Jxl matches JPEG XL image file.

func MachO

func MachO(raw []byte, limit uint32) bool

MachO matches Mach-O binaries format.

func Marc

func Marc(raw []byte, limit uint32) bool

Marc matches a MARC21 (MAchine-Readable Cataloging) file.

func Mkv

func Mkv(raw []byte, limit uint32) bool

Mkv matches a mkv file.

func Mp3

func Mp3(raw []byte, limit uint32) bool

Mp3 matches an mp3 file.

func Mpeg

func Mpeg(raw []byte, limit uint32) bool

Mpeg matches a Moving Picture Experts Group file.

func Msg

func Msg(raw []byte, limit uint32) bool

Msg matches a Microsoft Outlook email file.

func Msi added in v1.4.0

func Msi(raw []byte, limit uint32) bool

Msi matches a Microsoft Windows Installer file. http://fileformats.archiveteam.org/wiki/Microsoft_Compound_File

func NdJSON added in v1.4.0

func NdJSON(raw []byte, limit uint32) bool

NdJSON matches a Newline delimited JSON file.

func Ogg

func Ogg(raw []byte, limit uint32) bool

Ogg matches an Ogg file.

func OggAudio

func OggAudio(raw []byte, limit uint32) bool

OggAudio matches an audio ogg file.

func OggVideo

func OggVideo(raw []byte, limit uint32) bool

OggVideo matches a video ogg file.

func Ole

func Ole(raw []byte, limit uint32) bool

Ole matches an Open Linking and Embedding file.

https://en.wikipedia.org/wiki/Object_Linking_and_Embedding

func P7s

func P7s(raw []byte, limit uint32) bool

P7s matches an .p7s signature File (PEM, Base64).

func Php

func Php(raw []byte, limit uint32) bool

Php matches a PHP: Hypertext Preprocessor file.

func Ppt

func Ppt(raw []byte, limit uint32) bool

Ppt matches a Microsoft PowerPoint 97-2003 file or a PowerPoint 95 presentation.

func Pptx

func Pptx(raw []byte, limit uint32) bool

Pptx matches a Microsoft PowerPoint 2007 file.

func Pub

func Pub(raw []byte, limit uint32) bool

Pub matches a Microsoft Publisher file.

func Qcp

func Qcp(raw []byte, limit uint32) bool

Qcp matches a Qualcomm Pure Voice file.

func Rar

func Rar(raw []byte, limit uint32) bool

Rar matches a RAR archive file.

func Rpm

func Rpm(raw []byte, limit uint32) bool

Rpm matches an RPM or Delta RPM package file.

func Shp

func Shp(raw []byte, limit uint32) bool

Shp matches a shape format file. https://www.esri.com/library/whitepapers/pdfs/shapefile.pdf

func Shx

func Shx(raw []byte, limit uint32) bool

Shx matches a shape index format file. https://www.esri.com/library/whitepapers/pdfs/shapefile.pdf

func Svg

func Svg(raw []byte, limit uint32) bool

Svg matches a SVG file.

func Swf

func Swf(raw []byte, limit uint32) bool

Swf matches an Adobe Flash swf file.

func Text

func Text(raw []byte, limit uint32) bool

Text matches a plain text file.

TODO: This function does not parse BOM-less UTF16 and UTF32 files. Not really sure it should. Linux file utility also requires a BOM for UTF16 and UTF32.

func Tsv

func Tsv(raw []byte, limit uint32) bool

Tsv matches a tab-separated values file.

func Ttf

func Ttf(raw []byte, limit uint32) bool

Ttf matches a TrueType font file.

func Wav

func Wav(raw []byte, limit uint32) bool

Wav matches a Waveform Audio File Format file.

func WebM

func WebM(raw []byte, limit uint32) bool

WebM matches a WebM file.

func Webp

func Webp(raw []byte, _ uint32) bool

Webp matches a WebP file.

func Xls

func Xls(raw []byte, limit uint32) bool

Xls matches a Microsoft Excel 97-2003 file.

func Xlsx

func Xlsx(raw []byte, limit uint32) bool

Xlsx matches a Microsoft Excel 2007 file.

func Zip

func Zip(raw []byte, limit uint32) bool

Zip matches a zip archive.

func Zstd

func Zstd(raw []byte, limit uint32) bool

Zstd matches a Zstandard archive file.

Types

type Detector

type Detector func(raw []byte, limit uint32) bool

Notes

Bugs

  • Doc should look for subheaders like Ppt and Xls does.

    Ole is a container for Doc, Ppt, Pub and Xls. Right now, when an Ole file is detected, it is considered to be a Doc file if the checks for Ppt, Pub and Xls failed.

  • The "type" key should be searched for in the root object.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL