v151 · web platform · internals
XML Parsing in Rust for non-XSLT scenarios
Chrome replaced its C++ XML parser with a memory-safe Rust implementation for several common parsing scenarios (not including XSLT). This is an internal engine change that eliminates memory-related vulnerabilities — no new web-facing API.
concepts
The Rust rewrite is an internal implementation change — the web-facing DOMParser contract is unchanged. These demos exercise that observable contract live, so you can see exactly what the parser behind Chrome produces.
-
DOMParser Playground
Feed any XML to
DOMParser.parseFromStringand inspect the resulting DOM tree — or the<parsererror>that well-formedness violations (unclosed tags, mismatches, bare&, two roots) produce. -
Namespaces Explorer
Parse mixed-namespace XML and read the real
namespaceURI,prefix, andlocalNamethe parser assigns, then run a prefix-independentgetElementsByTagNameNSquery. -
Entities & CDATA
Watch predefined and numeric entities expand, CDATA sections stay literal as distinct nodes, and custom DTD entities hit the browser's deliberate security boundary.
why it shipped
XML parsing is a classic source of memory-safety vulnerabilities in browsers — malformed input driving buffer overflows and use-after-free bugs in C++. Rewriting the parser in Rust for the common non-XSLT paths removes that whole bug class using the language's ownership model, with no change to the observable parsing behaviour web developers depend on. It is invisible in day-to-day use and significant for browser security.