Fix possibility for arbitrary HTML output
Trusting the page content is inherently insecure. Instead, store the
parsed content in an array and output an index to retrieve it later.
Modernize code style slightly, while at it.
Bug: T88964
Change-Id: I00ede9c7f333f32f2cc7722781b06f97a544927f