avoid corrupt attachments, #13209 and #13877