My temporary work-around is to evaluate the user’s search term and if it equals a few of the HTML tags which break the code, I display an error message. I also display the message if the search term is less than 4 characters long.
Not perfect, but should eliminate 99% of chances to break the page for now.