I tried for the most helpful truncation. I figured that it's going to need this code so infrequently it's hardly worth the optimization. e.g. 99.9% of the time, the html is short enough. If I'm the first person to be affected by this bug, I guess it's not a major one.