falcon icon indicating copy to clipboard operation
falcon copied to clipboard

🐛 [BUG] - is_themecore hookActionOutputHTMLBefore broken html output

Open tomasz3k opened this issue 5 months ago • 2 comments

Description

I just came out with error when I write template file with <script>let test = '<div></div>';</script> Your hook changed it to <script>let test = '<div></script></section></div>';</script> and browser throwed error Uncaught SyntaxError: Invalid or unexpected token I spend hour to find out solution.

Node.js version

v20.10.0

php version

8.1

OS and it's version

MacOs 14.2.1 (23C71)

Browsers

Chrome

Required module/theme

is_themecore

Reproduction steps

Change 
` $doc->loadHTML(
            '<meta http-equiv="Content-Type" content="charset=utf-8">' . $html,
            LIBXML_NOERROR | LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD 
        );` 

to 
` $doc->loadHTML(
            '<meta http-equiv="Content-Type" content="charset=utf-8">' . $html,
            LIBXML_NOERROR | LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD | LIBXML_SCHEMA_CREATE
        );`

Logs

No response

tomasz3k avatar Jan 16 '24 11:01 tomasz3k

Hi @tomasz3k,

thank you for creating an issue. I was able to reproduce the problem. I am adding this to is_themecore roadmap. We came across a lot of problems with DOMDocument. I am not sure but we might get rid of it in is_themecore v5.

Oksydan avatar Jan 17 '24 07:01 Oksydan

I think there should be better way to manipulate HTML. DomDocument is easy but not best. It requires many extra flags to works as expected so it's platform dependant too. I am not sure is it the fastest way to manipulate DOM? Maybe you should just use some regex? It will require extra time for tests. Have a nice day.

tomasz3k avatar Jan 17 '24 08:01 tomasz3k