at the very start:
```javascript
var MAX_MIME_TYPE_LENGTH = 256; // ought to be enough for anybody 
if (typeof mime !== 'string' || mime.length > MAX_MIME_TYPE_LENGTH) {
  return null;
}
```