refactor into common-content

@jeremy @bf4

cleaning up some repetition and simplifying logic, also removing blank checks on filename, since we do not do them in content_disposition_field to avoid blowing up on invalid encoding