Fix incorrect script end tag detection in JS
This commit is contained in:
parent
2e5d560797
commit
d8f6bd457a
|
@ -43,7 +43,7 @@ class EsbuildAsync {
|
||||||
|
|
||||||
async finalise (html) {
|
async finalise (html) {
|
||||||
const jsTransformResults = await Promise.all(this.promises);
|
const jsTransformResults = await Promise.all(this.promises);
|
||||||
return html.replace(/_____ESBUILD_ASYNC_PLACEHOLDER_([0-9]+)_____/g, (_, id) => jsTransformResults[id].code.replace(/<\/script/g, '<\\/script'));
|
return html.replace(/_____ESBUILD_ASYNC_PLACEHOLDER_([0-9]+)_____/g, (_, id) => jsTransformResults[id].code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -384,8 +384,8 @@ impl<'d> Processor<'d> {
|
||||||
for (i, EsbuildSection { result, src }) in results.iter().enumerate() {
|
for (i, EsbuildSection { result, src }) in results.iter().enumerate() {
|
||||||
// Resulting minified JS/CSS to write.
|
// Resulting minified JS/CSS to write.
|
||||||
// TODO Verify.
|
// TODO Verify.
|
||||||
// TODO Rewrite these in esbuild fork so we don't have to do a memcpy and search+replace.
|
// TODO Handle potential `</script>` in output code, which could be in string (e.g. orig. "</" + "script>"), comment, or expression (e.g. orig. `a < /script>/.exec(b)?.length`).
|
||||||
let min_code = result.code.as_str().trim().replace("</script", "<\\/script");
|
let min_code = result.code.as_str().trim();
|
||||||
let min_len = if min_code.len() < src.len() {
|
let min_len = if min_code.len() < src.len() {
|
||||||
self.code[write_next..write_next + min_code.len()].copy_from_slice(min_code.as_bytes());
|
self.code[write_next..write_next + min_code.len()].copy_from_slice(min_code.as_bytes());
|
||||||
min_code.len()
|
min_code.len()
|
||||||
|
|
Loading…
Reference in New Issue