elharo opened a new pull request, #138: URL: https://github.com/apache/xerces-j/pull/138
## Summary Fixes [XERCESJ-1602](https://issues.apache.org/jira/browse/XERCESJ-1602). `HTMLSerializer` (and therefore `XHTMLSerializer`) serialized an empty non-void element such as `iframe` using the XML self-closing syntax: ```html <iframe src="http://example.com/" /> ``` That is invalid HTML for non-void elements: browsers do not treat `/>` as closing an `iframe`, so the element swallows the following content. ## Fix In `HTMLSerializer.endElementIO`, when serializing XHTML and the element is empty, only use the self-closing syntax for elements that are declared empty in HTML (e.g. `br`, `img`, `input`). Any other element is now written with an explicit end tag: ```html <iframe src="http://example.com/"></iframe> ``` Elements in a non-HTML namespace are still self-closed, and empty HTML void elements are still written as `<br />`. ## Tests Added `tests/dom/serialize/TestHTMLSerializer.java`, which verifies: * `HTMLSerializer` closes an empty `iframe` explicitly. * `XHTMLSerializer` closes an empty `iframe` explicitly (this test fails before the fix, reproducing the bug). * `XHTMLSerializer` still self-closes an empty void element such as `br`. The full `ant test` suite passes. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
