Conditional Comments not parsed properly
Brought to you by:
derrickoswald
An HTML file was sent to me by a colleague, the following is the bare-boned version of it:
<html> <body> <table> <tr> <td> <center> <!--[if !mso]><!-- --> <table> <!--<![endif]--> <tr> <td> Hello </td> </tr> </table> </center> </td> </tr> </table> </body> </html>
I know this is horrible practice to have the conditional comments in that form (or even to have conditional comments at all) but Firefox and Chrome are ok with opening this file but when I run it through the HTMLParser using:
NodeList nodes = new Parser( new Lexer( new Page( new BufferedInputStream(new FileInputStream(originalHtml)), "UTF-8")) ).parse(null);
nodes.toHtml() gives me the following:
<html> <body> <table> <tr> <td> <center> <!--[if !mso]><!-- --> <table> <!--<![endif]--> </td></tr><tr> <td> Hello </td> </tr> </table> </center> </td> </tr> </table> </body> </html>
Notice the added "" tags right after the "endif". Is there a workaround for this?
This should be a valid commented out block but maybe the lexer or parser is doing something else with it.