Correctly deal with invalid content in non-selfclosing tags. Fixes #297