You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Edge Side Includes (ESI) markup such as <esi:include src="..." /> is stripped and processed by a CDN/edge proxy before a browser ever sees it (see ESI Language Specification 1.0 §3.1), which specifies ESI elements as XML and include as an empty element with no closing tag. This markup is common in HTML served through Akamai/Fastly-style edge proxies.
Per the WHATWG HTML parsing spec, the trailing / on a non-void, non-foreign (non-SVG/MathML) element is not actually a self-closing indicator, so minify-html currently parses <esi:include src="..." /> as an ordinary opening tag that stays open until a matching </esi:include> is found. Since that closing tag never appears in real-world markup, the element swallows all following sibling content as its own children, silently corrupting the document structure.
Repro
use minify_html::{minify,Cfg};let html = br#"<div><esi:include src="/a" /><span>after</span></div>"#;let out = minify(html,&Cfg::new());println!("{}",String::from_utf8(out).unwrap());
Actual:<div><esi:include src=/a><span>after</span> — the <span> becomes a child of esi:include, and both the esi:include and outer div end up with no closing tags at all.
Expected: The self-closing esi:include tag (and its attributes) should be preserved verbatim, at least behind an opt-in config flag, so ESI-annotated HTML can be minified without breaking the edge proxy's ability to parse it.
Happy to submit a PR with a fix (adding a preserve_esi_include_tagsCfg option) if that approach sounds reasonable.
Activity
Add preserve_esi_tags option and update dependencies