Fix up whitelistHtml

There were a few nasty things going on here, but it looks fixed up, and
probably a mite faster too!

Thanks so much for the review, Krinkle.

Thanks to Gergo also for the better algo.

Change-Id: I630a1ad625abb803e31c7e7dd2cb4f4386d52607