Fix entity escaping on main pages

DOMDocument::createElement() expects HTML input while it used to receive
entity-deoded text. As a result, there's no XSS only because Parser sanitizes
input enough to prevent anything stupid. In addition to potential insecurity,
this bug also generated PHP warnings for some inputs.

Change-Id: If917097f97d0239aa2ebdeabe863b5786e92230c
(cherry picked from commit 9fa01505a100e63021a963505826d6baffb8f4bd)