Fix handling of invalid email addresses in headers (#1489092)