bogusfocused / html-webpack-inline-chunk-plugin

A webpack plugin that inlines chunk in html-webpack-plugin.
34 stars 6 forks source link

`<script>` and `</script>` not escaped cause inlined chunk to break parsing #7

Open jrencz opened 6 years ago

jrencz commented 6 years ago

One of dependencies of the module being entry point to a chunk inlined with html-webpack-inline-chunk-plugin has core-js in it. It contains this line

https://github.com/zloirock/core-js/blob/a08b6d46ea3f02a33b17df552e73078b42c5b78f/client/shim.js#L1109

(minified it looks like this: t.write("<script>document.F=Object<\/script>"))

Inlined it looks like this:

<script type="text/javascript>/* ... */t.write("<script>document.F=Object</script>")/* ... */</script>

Which breaks parsing. The script tag needs to be escaped

Related: https://wls.wwco.com/blog/2007/04/25/using-script-in-a-javascript-literal/ (yeah, it's old but it's definitely on tipic)