Ref T13053. This is intended to replace the incomplete fix in D17831, which stopped some bleeding but is not correct for all inputs.
This mostly appears to implement the rules in RFC2822, which don't seem exceptionally complex from the escaping side, even though it is well established that no computer can ever successfully parse an RFC2822 address.