Mirror of XHTML regression fix from master

1.x equivilant to gh-1375.