gluonhq / substrate

Create native Java(FX) apps for desktop, mobile and embedded
GNU General Public License v2.0
390 stars 52 forks source link

[Android] WebView: The element type "meta" must be terminated by the matching end-tag "</meta>" #1210

Closed jperedadnr closed 1 year ago

jperedadnr commented 1 year ago

Running HelloFX on Android with a WebView and loading the following valid HTML content:

<html><head><meta charset="UTF-8"><title>Title</title></head><body>test</body></html>

produces an exception that prevents passing the org.w3c.dom.Document object to the WebEngine::documentProperty

[Tue Mar 07 13:23:43 CET 2023][INFO] [SUB] D/GraalCompiled(20108): [Fatal Error] :1:63: The element type "meta" must be terminated by the matching end-tag "</meta>".
[Tue Mar 07 13:23:43 CET 2023][INFO] [SUB] D/GraalCompiled(20108): Error parsing html: The element type "meta" must be terminated by the matching end-tag "</meta>".
[Tue Mar 07 13:23:43 CET 2023][INFO] [SUB] V/GraalActivity(20108): LOAD onReceivedHttpError: request: GET
[Tue Mar 07 13:23:43 CET 2023][INFO] [SUB] V/GraalActivity(20108): LOAD onReceivedHttpError: errorResponse: 
[Tue Mar 07 13:23:43 CET 2023][INFO] [SUB] E/GraalGluon(20108): nativeFailedURL called. Invoke method on webView

JavaFX WebEngine parses HTML (HTML-5 with valid void tags) into XHTML (without valid void tags) with:

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(new InputSource(new StringReader(pageContent)));

and fails with such exception:

Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 57; The element type "meta" must be terminated by the matching end-tag "</meta>".
        at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:262)
        at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:342)
        at com.gluonhq.web.HelloWeb.start(HelloWeb.java:29)

Expected Behavior

Current Behavior

Steps to Reproduce

Your Environment