Skip to content

Commit

Permalink
Remove obsolete MIME types from IANA data
Browse files Browse the repository at this point in the history
  • Loading branch information
dougwilson committed May 14, 2022
1 parent c8e4e30 commit bbca7ce
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 183 deletions.
1 change: 1 addition & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ unreleased
==========

* Add new upstream MIME types
* Remove obsolete MIME types from IANA data

1.52.0 / 2022-02-21
===================
Expand Down
51 changes: 22 additions & 29 deletions db.json
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@
"source": "iana"
},
"application/ecmascript": {
"source": "iana",
"source": "apache",
"compressible": true,
"extensions": ["ecma"]
},
Expand Down Expand Up @@ -732,7 +732,7 @@
"extensions": ["class"]
},
"application/javascript": {
"source": "iana",
"source": "apache",
"charset": "UTF-8",
"compressible": true,
"extensions": ["js","mjs"]
Expand Down Expand Up @@ -1581,7 +1581,7 @@
"source": "iana"
},
"application/smil": {
"source": "iana"
"source": "apache"
},
"application/smil+xml": {
"source": "iana",
Expand Down Expand Up @@ -1916,10 +1916,6 @@
"source": "iana",
"compressible": true
},
"application/vnd.3gpp.mcvideo-affiliation-info+xml": {
"source": "iana",
"compressible": true
},
"application/vnd.3gpp.mcvideo-info+xml": {
"source": "iana",
"compressible": true
Expand Down Expand Up @@ -2105,7 +2101,7 @@
"extensions": ["age"]
},
"application/vnd.ah-barcode": {
"source": "iana"
"source": "apache"
},
"application/vnd.ahead.space": {
"source": "iana",
Expand Down Expand Up @@ -2218,7 +2214,7 @@
"extensions": ["pkpass"]
},
"application/vnd.arastra.swi": {
"source": "iana"
"source": "apache"
},
"application/vnd.aristanetworks.swi": {
"source": "iana",
Expand Down Expand Up @@ -2976,11 +2972,11 @@
"extensions": ["fm","frame","maker","book"]
},
"application/vnd.frogans.fnc": {
"source": "iana",
"source": "apache",
"extensions": ["fnc"]
},
"application/vnd.frogans.ltf": {
"source": "iana",
"source": "apache",
"extensions": ["ltf"]
},
"application/vnd.fsc.weblaunch": {
Expand Down Expand Up @@ -3070,11 +3066,11 @@
"compressible": true
},
"application/vnd.geo+json": {
"source": "iana",
"source": "apache",
"compressible": true
},
"application/vnd.geocube+xml": {
"source": "iana",
"source": "apache",
"compressible": true
},
"application/vnd.geogebra.file": {
Expand Down Expand Up @@ -3277,7 +3273,7 @@
"source": "iana"
},
"application/vnd.ibm.afplinedata": {
"source": "iana"
"source": "apache"
},
"application/vnd.ibm.electronic-media": {
"source": "iana"
Expand All @@ -3287,7 +3283,7 @@
"extensions": ["mpy"]
},
"application/vnd.ibm.modcap": {
"source": "iana",
"source": "apache",
"extensions": ["afp","listafp","list3820"]
},
"application/vnd.ibm.rights-management": {
Expand Down Expand Up @@ -3363,7 +3359,7 @@
"compressible": true
},
"application/vnd.informix-visionary": {
"source": "iana"
"source": "apache"
},
"application/vnd.infotech.project": {
"source": "iana"
Expand Down Expand Up @@ -4072,7 +4068,7 @@
"extensions": ["ngdat"]
},
"application/vnd.nokia.n-gage.symbian.install": {
"source": "iana",
"source": "apache",
"extensions": ["n-gage"]
},
"application/vnd.nokia.ncd": {
Expand Down Expand Up @@ -4266,7 +4262,7 @@
"compressible": true
},
"application/vnd.oma.bcast.drm-trigger+xml": {
"source": "iana",
"source": "apache",
"compressible": true
},
"application/vnd.oma.bcast.imd+xml": {
Expand Down Expand Up @@ -4297,7 +4293,7 @@
"source": "iana"
},
"application/vnd.oma.bcast.smartcard-trigger+xml": {
"source": "iana",
"source": "apache",
"compressible": true
},
"application/vnd.oma.bcast.sprov+xml": {
Expand Down Expand Up @@ -5639,9 +5635,6 @@
"source": "iana",
"extensions": ["cmp"]
},
"application/vnd.youtube.yt": {
"source": "iana"
},
"application/vnd.zul": {
"source": "iana",
"extensions": ["zir","zirz"]
Expand Down Expand Up @@ -6935,7 +6928,7 @@
"source": "iana"
},
"audio/vnd.qcelp": {
"source": "iana"
"source": "apache"
},
"audio/vnd.rhetorex.32kadpcm": {
"source": "iana"
Expand Down Expand Up @@ -7533,7 +7526,7 @@
"compressible": true
},
"message/news": {
"source": "iana"
"source": "apache"
},
"message/partial": {
"source": "iana",
Expand All @@ -7545,7 +7538,7 @@
"extensions": ["eml","mime"]
},
"message/s-http": {
"source": "iana"
"source": "apache"
},
"message/sip": {
"source": "iana"
Expand All @@ -7557,7 +7550,7 @@
"source": "iana"
},
"message/vnd.si.simp": {
"source": "iana"
"source": "apache"
},
"message/vnd.wfa.wsc": {
"source": "iana",
Expand Down Expand Up @@ -7829,7 +7822,7 @@
"source": "iana"
},
"text/ecmascript": {
"source": "iana"
"source": "apache"
},
"text/encaprtp": {
"source": "iana"
Expand Down Expand Up @@ -8106,7 +8099,7 @@
"source": "iana"
},
"text/vnd.si.uricatalogue": {
"source": "iana"
"source": "apache"
},
"text/vnd.sosi": {
"source": "iana"
Expand Down Expand Up @@ -8500,7 +8493,7 @@
"source": "iana"
},
"video/vnd.radgamettools.smacker": {
"source": "iana"
"source": "apache"
},
"video/vnd.sealed.mpeg1": {
"source": "iana"
Expand Down
17 changes: 12 additions & 5 deletions scripts/fetch-iana.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ var toArray = require('stream-to-array')
var writedb = require('./lib/write-db')

var extensionsQuotedRegExp = /^\s*(?:\d\.\s+)?File extension(?:\(s\)|s|)\s?:(?:[^'"\r\n]+)(?:"\.?([0-9a-z_-]+)"|'\.?([0-9a-z_-]+)')/im
var intendedUsageRegExp = /^\s*(?:(?:\d{1,2}\.|o)\s+)?Intended\s+Usage\s*:\s*(\S+)/im
var leadingSpacesRegExp = /^\s+/
var listColonRegExp = /:(?:\s|$)/m
var nameWithNotesRegExp = /^(\S+)(?: - (.*)$| \((.*)\)$|)/
Expand All @@ -33,6 +32,7 @@ var urlReferenceRegExp = /\[(https?:\/\/[^\]]+)]/gi

var CHARSET_DEFAULT_REGEXP = /(?:\bcharset\b[^.]*(?:\.\s+default\s+(?:value\s+)?is|\bdefault[^.]*(?:of|is)|\bmust\s+have\s+the\s+value|\bvalue\s+must\s+be)\s+|\bcharset\s*\(?defaults\s+to\s+|\bdefault\b[^.]*?\bchar(?:set|act[eo]r\s+set)\b[^.]*?(?:of|is)\s+|\bcharset\s+(?:must|is)\s+always\s+(?:be\s+)?)["']?([a-z0-9]+-[a-z0-9-]+)/im
var EXTENSIONS_REGEXP = /(?:^\s*(?:\d\.\s+)?|\s+[23]\.\s+)[Ff]ile [Ee]xtension(?:\(s\)|s|)\s?:\s+(?:\*\.|\.|)([0-9a-z_-]+|[0-9A-Z_-]+)(?:\s+or\s+(?:\*\.|\.|)([0-9a-z_-]+|[0-9A-Z_-]+)\s*)?(?:\s*[34]\.\s+|\s+[A-Z(]|\s*$)/m
var INTENDED_USAGE_REGEXP = /^\s*(?:(?:\d{1,2}\.|o)\s+)?Intended\s+Usage\s*:\s*([0-9a-z]+)/im
var MIME_SUBTYPE_LINE_REGEXP = /^[^:\s-]*\s*(?:MIME )?(?:[Mm]edia )?(?:[Ss]ub ?type|SUB ?TYPE)(?: (?:[Nn]ame|NAME))?\s*:\s+(?:[A-Za-z]+ [Tt]ree\s+(?:- ?)?|(?:[a-z]+ )+- )?([0-9A-Za-z][0-9A-Za-z_.+-]*)(?:\s|$)/m
var MIME_TYPE_HAS_CHARSET_PARAMETER_REGEXP = /parameters\s*:[^.]*\bcharset\b/im

Expand Down Expand Up @@ -78,6 +78,11 @@ co(function * () {
throw new Error('duplicate entry for ' + mime)
}

// skip obsoleted mimes
if (result.usage === 'obsolete') {
return
}

json[mime] = {
charset: result.charset,
notes: result.notes,
Expand Down Expand Up @@ -145,10 +150,12 @@ function addTemplateData (data, options) {
// use extracted charset
data.charset = extractTemplateCharset(body)

// use extracted usage
data.usage = extractIntendedUsage(body)

// use extracted extensions
var useExt = opts.extensions &&
(opts.extensions === true || opts.extensions.test(data.mime))
if (useExt && extractIntendedUsage(body) === 'common') {
if (data.usage === 'common' && opts.extensions &&
(opts.extensions === true || opts.extensions.test(data.mime))) {
data.extensions = extractTemplateExtensions(body)
}
}
Expand All @@ -158,7 +165,7 @@ function addTemplateData (data, options) {
}

function extractIntendedUsage (body) {
var match = intendedUsageRegExp.exec(body)
var match = INTENDED_USAGE_REGEXP.exec(body)

return match
? match[1].toLocaleLowerCase()
Expand Down

0 comments on commit bbca7ce

Please sign in to comment.