simplify mimetype parsing of 'file' output

backport of #1527 to stable45