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.

  1. DOMParser Playground

    Feed any XML to DOMParser.parseFromString and inspect the resulting DOM tree — or the <parsererror> that well-formedness violations (unclosed tags, mismatches, bare &, two roots) produce.

  2. Namespaces Explorer

    Parse mixed-namespace XML and read the real namespaceURI, prefix, and localName the parser assigns, then run a prefix-independent getElementsByTagNameNS query.

  3. 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.

references