jeffcjohnson · GitHub

The parser will allow an ampersand in the title tag but fails in some instances. The following will cause it to treat all HTML that follows as plain text:

String htmlCode = "<html><head><title>&X</title></head</html>";

System.out.println(page.getTitleText());
prints &x</title></head</html> instead of &x.

The full code to reproduce:

"import com.gargoylesoftware.htmlunit.BrowserVersion; import com.gargoylesoftware.htmlunit.StringWebResponse; import com.gargoylesoftware.htmlunit.WebClient; import com.gargoylesoftware.htmlunit.html.HTMLParser; import com.gargoylesoftware.htmlunit.html.HtmlPage; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; public class HtmlUnitTest { public static void main(String[] args) { String htmlCode = "

Read the original on github.com ↗