Curing the Vulnerable Parser: Design Patterns for Secure Input Handling