Skip to content

v1.15.11

Choose a tag to compare

@github-actions github-actions released this 16 Nov 01:02
Immutable release. Only release title and notes can be modified.

Bug fixes

  • Prevent phone-number extensions with many separators from writing past the recognizer's chunk buffer. Preserve XML comment boundaries after invalid controls are removed and exact carriage returns and line feeds in CLI text files. Deeply nested XPath expressions now raise XPathDepthError during parsing, matching evaluation (#1675) by @gaborbernat.
  • Element.insert() and ElementView.insert() no longer slow down with the number of siblings when inserting near either end of a long child list (#2150) by @gaborbernat. (#1695)
  • After a handler edit, rewrite writes the markup that follows, and a < the edit left before it, so a browser reads them as it read the input (#2146) by @gaborbernat. (#1701)
  • XML Schema validation now rejects child elements in an element declared with an inline xs:simpleType, as it already does for a type= declaration (#2127) by @gaborbernat. (#1708)
  • Reading or clearing every attribute of an element with many attributes, or removing them by name from either end, now takes time linear in the attribute count (#2174) by @gaborbernat. (#1709)
  • Multi-step XSD extensions now require every base type's content, so complete documents are accepted and incomplete ones rejected; invalid xs:all extensions now raise (#2135) by @gaborbernat. (#1716)
  • Keep computed_style fast on deeply nested documents in any call order, instead of restyling every ancestor on each call (#2181) by @gaborbernat. (#1718)
  • Sanitizer checks now judge each value as the XML serializer writes it too, so dropped control characters can no longer rejoin CSS, URLs, or template markers the checks refused (#2116) by @gaborbernat. (#1728)
  • Minified CSS keeps the separator after a name ending in an escaped character, so the output parses as the input did (#2161) by @gaborbernat. (#1729)
  • Read <meta http-equiv=refresh> targets as browsers do, so links(), rewrite_links(), resolve_links() and meta_refresh() agree, and text right after the delay is no redirect (#2126) by @gaborbernat. (#1737)
  • A loop of Range calls over the children of one wide element no longer slows down with the square of the child count (#2144) by @gaborbernat. (#1743)
  • minify_css no longer brings to life an @import, @namespace, @charset or @layer statement that browsers ignore, and keeps an empty rule that holds one back (#2145) by @gaborbernat. (#1745)
  • XPath regex searches with back-references now count every capture group against the step limit, so such patterns raise ValueError instead of running past it (#2131) by @gaborbernat. (#1746)
  • XPath expressions that nest predicates or operators around matches(), replace() or extension functions no longer slow down with each level of nesting (#2179) by @gaborbernat. (#1748)
  • rewrite() no longer adds a tag where an empty end tag or removed node sat between a < and text, including raw text past the nesting cap (#2195) by @gaborbernat. (#1752)
  • Keep the doctype's public and system identifiers and forced quirks mode in to_source, so the output reparses in the source's document mode (#2141) by @gaborbernat. (#1757)
  • rewrite() no longer lets a removed <script> through on pages nested past 8,192 open elements; edits it cannot apply there raise ValueError (#2196) by @gaborbernat. (#1758)
  • Link extraction, rewriting and sanitizing now read srcset candidates like a browser: commas inside parentheses no longer split a candidate, and candidates with invalid descriptors are skipped (#2148) by @gaborbernat. (#1759)
  • Repeatedly assigning Text.data, Comment.data or the etree text and tail properties now keeps memory proportional to the current text instead of every value assigned (#2133) by @gaborbernat. (#1760)
  • Minifying a style attribute now drops the rest of a declaration broken by a {} block or a stray }, rather than letting it apply (#2151) by @gaborbernat. (#1763)
  • XML Schema and RELAX NG range facets now judge the whole of a long numeric value instead of a truncated prefix of it (#2164) by @gaborbernat. (#1764)
  • xs:list and xs:union values are now checked against their item or member types, including xs:NMTOKENS, xs:IDREFS and xs:ENTITIES, instead of accepting any text (#2147) by @gaborbernat. (#1765)
  • Style attributes and <style> bodies no longer keep properties outside css_properties that browsers apply, and drop declarations containing a unicode-range token (#2137) by @gaborbernat. (#1768)
  • Edits that leave <style> elements alone no longer make computed_style recompile every sheet, and changes to a style's type or text apply at once (#2166) by @gaborbernat. (#1770)
  • A code block whose language contains a backtick is now fenced without that language, so its text stays code instead of being read as Markdown (#2153) by @gaborbernat. (#1771)
  • Serialized and minified HTML no longer lets a script run past its end tag and turn later content into live markup (#2173) by @gaborbernat. (#1773)
  • Long <meta> charset values are read in full, so padded labels resolve, and a charset that names no encoding no longer hides a content declaration, as in browsers (#2155) by @gaborbernat. (#1775)
  • minify output now reads the same in browsers that run scripts: <noscript> content is copied from the source, and a page whose <noscript> content parses differently there keeps everything after it unminified (#2154) by @gaborbernat. (#1776)
  • XPath function calls with many arguments now run in linear time when the expression uses regex or extension functions (#2156) by @gaborbernat. (#1778)
  • minify_css keeps the separators that a unicode-range start, an unclosed calc() or a universal selector needs, and stops crashing on some bang comments (#2198) by @gaborbernat. (#1835)
  • minify_css keeps a hash color that contains a CSS escape as written instead of shortening it, so the escape no longer swallows the closing brace of its rule (#2191) by @gaborbernat. (#1849)
  • minify_css keeps a rule whose selector starts with a combinator, such as > or ~, rather than dropping it or merging it into the rule before (#2192) by @gaborbernat. (#1850)
  • CSS minification now keeps a selector with three or more colons as written, and minifying the output again changes nothing (#2200) by @gaborbernat. (#1851)
  • Minified CSS no longer glues a calc()-unwrapped value to the token after it, and a calc() group left open at end of input folds in one pass (#2197) by @gaborbernat. (#1852)
  • Minifying CSS with stray brackets, hex escapes or CDO/CDC tokens now gives the same output on a second pass, drops declarations whose name holds a bracket, and folds an unclosed nested calc() (#2194) by @gaborbernat. (#1853)
  • Sanitized markup now re-parses to the same tree when an option or optgroup would otherwise nest inside an option (#1856) by @gaborbernat. (#1854)
  • Reparsing serialized output no longer changes a selectedcontent placed after its option (#1861) by @gaborbernat. (#1859)
  • Sanitized output no longer writes implied tbody, tr, or colgroup tags a policy omits; REMOVE now keeps cells under them (#1862) by @gaborbernat. (#1860)
  • Content after a table element or template refused at the nesting limit is kept, and a refused template's end tag closes only that template (#1865) by @gaborbernat. (#1863)
  • Serialization writes carriage returns as &#13; in text and attribute values, so sanitized and minified output stays unchanged when parsed and serialized again (#1866) by @gaborbernat. (#1864)
  • Named groups holding an xs:all now accept their children in any order, and an xs:all nested in a sequence or choice fails to compile (#2028) by @gaborbernat. (#2015)
  • XSD validation now accepts valid content for repeated particles with minOccurs of two or more whose repetitions can match no children (#2075) by @gaborbernat. (#2017)
  • Canonical XML and XML serialization now drop characters XML 1.0 forbids from CDATA sections, text and attribute values, so the output parses (#2039) by @gaborbernat. (#2024)
  • canonicalize on HTML-parsed trees now renders the xmlns: declarations that prefixed names use, so the output reparses in the same namespaces; a relative namespace URI raises ValueError (#2040) by @gaborbernat. (#2025)
  • A schema that repeats an xs:all group, through a group reference or an xs:all element with maxOccurs above 1, now fails to compile (#2031) by @gaborbernat. (#2029)
  • A schema that extends an xs:all content model with particles now fails to compile, and an extension without particles validates the base's members in any order (#2042) by @gaborbernat. (#2032)
  • Schemas that set minOccurs or maxOccurs on an xs:all, xs:sequence, or xs:choice inside an xs:group now fail to compile instead of ignoring the occurrence (#2071) by @gaborbernat. (#2060)
  • XML output and canonicalize() now keep each element in its namespace when the parent element is left out because its name is not a valid XML name (#2063) by @gaborbernat. (#2062)
  • RELAX NG validation of a repeated interleave of optional children now takes time linear in the number of children, and some such schemas no longer raise as too ambiguous (#2076) by @gaborbernat. (#2064)
  • Validating with a shared RelaxNG schema no longer writes into its compiled patterns, which raced with concurrent validations on free-threaded builds (#2118) by @gaborbernat. (#2108)
  • xsl:number level="multiple" now prints a number for every counted ancestor of a deeply nested element, where it used to drop the outermost ones (#2134) by @gaborbernat. (#2120)
  • XSLT copies and created elements in no namespace now stay in no namespace when the output is parsed again under a default namespace, as in libxslt (#2136) by @gaborbernat. (#2122)
  • css_path no longer hangs on a detached parse_fragment root that has an id (#2140) by @gaborbernat. (#2124)
  • XMLSchema validation now rejects attributes on elements with a simple type, except namespace declarations and the xsi: attributes the XSD spec allows (#2138) by @gaborbernat. (#2128)
  • Building an Element from many attributes, and sanitizing with a policy that forces many attributes on one tag, no longer slows down quadratically (#2143) by @gaborbernat. (#2142)
  • minify_css no longer starts its output with an @charset rule unless the input did, so browsers decode the output as they decode the input (#2160) by @gaborbernat. (#2149)
  • XSLT xsl:copy and xsl:copy-of now keep the namespace declarations in scope at the copied element, so prefixed names stay bound in the output (#2170) by @gaborbernat. (#2152)
  • minify_css() and minify_css_inline() keep every /*! ... */ bang comment, including those inside rules or declarations they drop (#2163) by @gaborbernat. (#2157)
  • Serializing after an allocation failure now raises MemoryError instead of returning wrong Markdown or corrupting memory during canonicalization (#2168) by @gaborbernat. (#2158)
  • XMLSchema and RelaxNG validation now rejects text outside the lexical forms of the ID, IDREF, ENTITY, NOTATION and g* date built-in types instead of accepting any value (#2185) by @gaborbernat. (#2159)
  • minify_css treats a leading byte-order mark as the encoding signature, so the first rule after it is no longer dropped (#2172) by @gaborbernat. (#2162)
  • Literal result elements keep the namespace declarations their own names and attributes need, even when exclude-result-prefixes lists those prefixes (#2188) by @gaborbernat. (#2165)
  • XPath results that combine nodes from detached subtrees and the document now come back in the same order on every platform, with each tree's nodes kept together (#2176) by @gaborbernat. (#2167)
  • xsl:element now creates its element in the namespace of its namespace attribute and declares that namespace in the output, so the result parses as XML (#2186) by @gaborbernat. (#2169)
  • Running out of memory while compiling or validating an XML Schema or RELAX NG schema now always raises MemoryError, not ValueError (#2177) by @gaborbernat. (#2171)
  • Minifying a document again no longer changes the output: end tags and the body start tag stay where the reparse needs them (#2184) by @gaborbernat. (#2182)
  • Schema validation and compilation on a worker thread with a small C stack now raise RecursionError for deeply nested schemas instead of crashing the interpreter (#2189) by @gaborbernat. (#2187)
  • Selector queries with a long :has() argument on a very deep tree no longer use memory that grows with selector length times depth (#2203) by @gaborbernat. (#2201)
  • minify_css_inline() no longer repeats a bang comment that sits inside an unclosed or invalid CSS function on each pass (#2207) by @gaborbernat. (#2204)
  • XPath name tests over XML documents now follow XPath 1.0: an unprefixed name skips default-namespace elements, and a prefix bound in namespaces= matches them (#2215) by @gaborbernat. (#2211)
  • XSLT select, test and attribute value template expressions now resolve a prefix declared on the stylesheet root or on the instruction itself, instead of raising an undefined prefix error (#2217) by @gaborbernat. (#2213)
  • computed_style() now returns the right color for an element when several rules in a stylesheet use :nth-child() or :nth-last-child() with an of selector list (#2221) by @gaborbernat. (#2220)
  • XMLSchema and RelaxNG now resolve non-ASCII namespace prefixes and match non-ASCII attribute names to the declarations they name (#2088) by @gaborbernat.
  • rewrite and Minify output no longer make a valueless attribute take the next attribute's name as its value when that name starts with = (#1965) by @gaborbernat.
  • tokenize, Tokenizer and HTMLParser now tokenize <title>, <style>, <script> and CDATA inside <svg> and <math> as browsers do (#1988) by @gaborbernat.
  • form_data now collects the controls inside SVG and MathML elements named datalist, template or fieldset, and such elements no longer disable them (#2083) by @gaborbernat.
  • find and find_all no longer crash when a regex or callable filter edits the tree during the search; the search carries on from the element it reached (#2053) by @gaborbernat.
  • to_source now escapes < and & in text it copies from the source, so that text can no longer come back as markup (#2123) by @gaborbernat.
  • to_source now writes the end tag of an element the source left open, unless HTML makes that tag optional there (#2115) by @gaborbernat.
  • A link nested in another link's text is written as its text only, so the outer link keeps its destination and title in to_markdown (#2072) by @gaborbernat.
  • A recursive XSLT stylesheet on a small-stack thread now raises RecursionError instead of crashing, and a very deep one may fail where it used to finish (#1891) by @gaborbernat.
  • A stylesheet or RELAX NG schema that reads more than 1,024 referenced files or 8 MiB through them now raises ValueError (#2026) by @gaborbernat.
  • An XPath predicate that fails while a walk covers several nodes now raises its own error, not a SystemError (#2199) by @gaborbernat.
  • An element with simple content is now checked against the facets of its base type and of its own restriction (#1996) by @gaborbernat.
  • Attributes with non-ASCII names are no longer read as charset, http-equiv, content or shadowroot*, so they no longer set the encoding or attach a shadow root (#2011) by @gaborbernat.
  • Build XSLT generate-id() values from node creation order, so transform output no longer contains heap addresses (#1887) by @gaborbernat.
  • CSS url() and @import targets are now read and written back the way browsers read them, so rewritten links no longer change where a stylesheet ends (#1977) by @gaborbernat.
  • Converting each item of a long list with its own to_markdown() call now takes linear time instead of quadratic time (#2119) by @gaborbernat.
  • Deeply nested XPath expressions now raise ValueError instead of crashing the interpreter when run on a thread with a small stack (#1892) by @gaborbernat.
  • Edited start tags in rewrite keep long attribute names whole, and by-name handler calls on tags with many attributes now run in linear time (#1993) by @gaborbernat.
  • Editing a deeply nested tree during iter_elements no longer takes quadratic time, and an element moved back under the iterated node is bounded by it again (#2099) by @gaborbernat.
  • Editing nodes watched by many separate MutationObserver objects no longer slows down with the number of watched nodes (#1966) by @gaborbernat.
  • Enforce minInclusive, maxInclusive, minExclusive and maxExclusive on xs:date, xs:dateTime, xs:time and xs:duration in XMLSchema and RelaxNG; values outside the bounds were accepted (#1888) by @gaborbernat.
  • Feed extraction reports out-of-memory failures while resolving RDF item references instead of continuing past them (#1970) by @gaborbernat.
  • Fix a crash when a callback moved the walked node into another tree; xpath now raises ValueError if its variables move the context node (#1927) by @gaborbernat.
  • Fix same-scheme base URLs and meta refresh targets ending in a colon resolving to the page URL instead of the URL they name (#2022) by @gaborbernat.
  • Hosts ending in a dot now group with their sibling hosts for external_only=True links, and no longer read past the end of such a host (#1985) by @gaborbernat.
  • Hosts ending in several dots now group with their sibling hosts for external_only=True links, and hosts with an empty label before their domain stay separate (#2000) by @gaborbernat.
  • Indented Markdown code blocks are fenced wherever a reader would read them as paragraph text, and a list's first item after text gets a blank line before it (#2023) by @gaborbernat.
  • Keep scale() and translate() arguments whole during CSS minification when a string, comment or block in them holds a comma, so the rest of the stylesheet keeps its meaning (#1874) by @gaborbernat.
  • Keep a CSS string whole when a newline follows a hex escape inside it, so minify_css no longer drops the declaration (#1990) by @gaborbernat.
  • Keep an escaped whitespace that ends a CSS url() when minifying, so its backslash cannot escape the closing ) (#1958) by @gaborbernat.
  • Keep content after a raw-text element such as textarea or noframes in the right place when it is nested past the depth limit (#1902) by @gaborbernat.
  • Keep every <frame> after a <frameset> refused at the nesting limit, instead of dropping some of them (#1878) by @gaborbernat.
  • Keep paragraphs inside deeply nested list items when converting HTML to Markdown (#1677) by @gaborbernat.
  • Keep the sanitizer from trimming whitespace that ends an unterminated string or follows a backslash, which let unlisted CSS properties survive in <style> bodies (#1972) by @gaborbernat.
  • Linking a node that is an anchor, or sits inside one, no longer adds links within that anchor. Text under an anchor is left as written (#1909) by @gaborbernat.
  • Links with extra slashes before their host now resolve to that host instead of the page's own host, even when tabs or newlines hide the slashes (#1880) by @gaborbernat.
  • Looping over the children of a long turbohtml.etree element by position is no longer quadratic in their count (#1959) by @gaborbernat.
  • Markdown export writes a white-space: pre element that would start a line as a span, not pre, and escapes list and heading markers after <sub> and <sup> (#2121) by @gaborbernat.
  • Markdown output no longer puts <q> quote marks on code fence lines. A quote starting with a block now puts its marks on their own lines (#2081) by @gaborbernat.
  • Minifying CSS ends a url() where a browser does, so a comment or quote inside one can no longer keep or drop declarations it should not (#2098) by @gaborbernat.
  • Minifying CSS keeps a name that follows u+ and hex digits whole, with its arguments in the same value (#2102) by @gaborbernat.
  • Minifying CSS keeps a sheet's meaning when an unquoted url() holds a quote, and keeps attr() and if() values with a backslash before a newline (#1999) by @gaborbernat.
  • Minifying CSS now reads a backslash before a newline as browsers do, dropping declarations that hold one unless they are custom properties or use var() or env() (#1980) by @gaborbernat.
  • Minifying JavaScript, running an XSLT transform, or evaluating an XPath expression that nests deeper than a small thread stack holds now raises an error instead of crashing the process (#2125) by @gaborbernat.
  • Minifying keeps the end tags that a reparse needs in ruby, select, list and definition markup, so some output keeps a few more tags (#2030) by @gaborbernat.
  • Minifying the output of minify_css or minify_css_inline again no longer changes stylesheets whose identifiers or at-keywords end in a hex escape (#1836) by @gaborbernat.
  • Moving an element from a parse_xml tree into an HTML tree no longer takes time quadratic in the number of attributes on that element (#2112) by @gaborbernat.
  • Name the referenced path, not the target its symlinks resolve to, when an import or include escapes its root (#1992) by @gaborbernat.
  • Ordered lists in Markdown output now cap item numbers at 999,999,999, so a start or value above that no longer turns an item into a paragraph (#1871) by @gaborbernat.
  • Preserve CSS escape terminators, head content after repeated HTML tags, and spaces in Markdown table link destinations (#1665) by @gaborbernat.
  • RELAX NG and XSD validation now takes time linear in the document size, however its elements are arranged (#2041) by @gaborbernat.
  • Raise ValueError from rewrite when text written into an unclosed raw-text element would end it early, and escape text written past the nesting cap (#2097) by @gaborbernat.
  • Range comparison methods raise ValueError instead of crashing or returning a result when an edit leaves the boundaries in separate trees (#1932) by @gaborbernat.
  • Range edits that wrap, cut or insert inside one long text node no longer keep a copy of the remaining text for each edit (#2105) by @gaborbernat.
  • Reading tables with rows(), records() or tables() now raises MemoryError when memory runs out, instead of SystemError (#1963) by @gaborbernat.
  • Reject NaN in XSD validation when minInclusive, maxInclusive, minExclusive or maxExclusive bounds an xs:double or xs:float, as RELAX NG validation already does (#1968) by @gaborbernat.
  • Removing nodes while a NodeIterator is live no longer slows with how deeply its root or reference sits in the document (#2100) by @gaborbernat.
  • Resolve itemref against the document microdata() is called on, so a copied document no longer crashes it (#1989) by @gaborbernat.
  • SVG element names containing non-ASCII characters keep the spelling they were written with, instead of being renamed to a standard SVG name (#1954) by @gaborbernat.
  • Selector queries with :has() on trees nested many levels deep no longer slow down depending on where the tree sits in memory (#2014) by @gaborbernat.
  • Sets and dicts of elements built from freshly created and appended nodes no longer take quadratic time, since their hashes no longer collide (#1956) by @gaborbernat.
  • Stop iter_elements from crashing when linkify_node unwraps or replaces a link the walk is about to visit (#1994) by @gaborbernat.
  • Stop indenting a list nested directly in a list before its first item, so Markdown code fences stay fences and plain text loses the stray indent (#1991) by @gaborbernat.
  • Stop the sanitizer keeping a <style> inside a <textarea>, <svg> or <math>, and drop comments inside a <textarea>, where a reparse turns them into markup (#1875) by @gaborbernat.
  • Stylesheets that define one xsl:attribute-set name many times no longer use memory that grows quadratically; some circular-reference errors name another cycle (#1908) by @gaborbernat.
  • Taking css_path() or xpath_path() of every element now takes time linear in the document, and anchors added by linkify_node() appear in later find_all() and select() results (#2047) by @gaborbernat.
  • Text after a raw table, list, lone tag or pipe table in to_markdown output is no longer read as raw HTML or a table row (#2106) by @gaborbernat.
  • Unwrapping a raw-text element such as script, textarea or noscript in a rewrite handler now keeps its content as escaped text (#1883) by @gaborbernat.
  • Validating against a schema pattern no longer slows down with the number of members a character class lists (#2114) by @gaborbernat.
  • Validation of deeply nested XML documents against XML Schema and RELAX NG no longer crashes worker threads with small stacks (#2061) by @gaborbernat.
  • With Markdown.Images(mode="alt"), markup in an image's alt text is now escaped like prose, so it no longer reaches a Markdown reader as HTML (#2103) by @gaborbernat.
  • XML Schema and RELAX NG validation reject dates whose day does not exist in their month, such as February 29 in common years (#1900) by @gaborbernat.
  • XSD validation now accepts an empty element where a complex type's optional xs:all content allows no children (#2056) by @gaborbernat.
  • XSLT generate-id() now gives attribute and namespace nodes ids that differ from their element's and from each other (#1904) by @gaborbernat.
  • XSLT expressions, keys and xsl:number now take attribute nodes as context, generate-id() gives each attribute its own id, and key patterns with alternatives match all of them (#2052) by @gaborbernat.
  • ElementView.drop_tree() no longer copies the tail onto the dropped element, so repeated drops within one parent take linear time (#1935) by @gaborbernat.
  • Minify output of a parse_xml doctype with > in its system identifier no longer reparses the rest of the identifier as markup, and drops the identifiers instead (#2096) by @gaborbernat.
  • Node.encode with Html(meta_charset=True) no longer declares a codec that no WHATWG encoding label names, such as iso2022_jp_2, hz, or UTF-16, which browsers could not read back; it raises ValueError instead by Bernát Gábor.
  • Node.encode with Html(meta_charset=True) now declares the WHATWG name of the encoding it writes, so iso2022_jp declares ISO-2022-JP where it used to declare a codec name browsers ignore. UTF-8 is declared as utf-8, the spelling serialize() uses (#1838) by @gaborbernat.
  • Node.find() and Node.find_all() with a regex or callable text no longer write out of bounds when a callable filter adds elements mid-search, and skip those elements (#1995) by @gaborbernat.
  • XMLSchema and RelaxNG validation raises TypeError for a node that is neither a document nor an element, instead of crashing the interpreter (#1973) by @gaborbernat.
  • clean_url and extract_links no longer cut a URL inside its authority when the cut would change the host, so links to other sites stay visible (#1974) by @gaborbernat.
  • clean_url and extract_links now keep links whose host is a web host only once canonicalized, and return the canonical form (#1982) by @gaborbernat.
  • linkify_node no longer crashes when a link callback removes the text or <a> it is linking; the removed node keeps what the callback left (#1957) by @gaborbernat.
  • minify_css keeps time and memory linear when a short rule repeats a much longer rule's selector; the short rule now stays separate (#1915) by @gaborbernat.
  • parse(bytes) and detect() no longer cut a <meta> name or value at a NUL byte, so a label containing one no longer selects an encoding (#1939) by @gaborbernat.
  • rewrite() now reads markup in and around <svg>, <math>, <template> and <frameset> as browsers do, so handlers see every element a browser builds there (#2002) by @gaborbernat.
  • xs:duration values with a fraction of a second, such as PT1.5S, now validate, and range facets order them by their full value (#1905) by @gaborbernat.
  • xsl:import and RELAX NG hrefs that percent-decode to a UNC path are now rejected, as undecoded UNC hrefs already were (#1962) by @gaborbernat.
  • article() now raises MemoryError when memory runs out while reading page metadata, instead of silently dropping fields (#1978) by @gaborbernat.

Security

  • RELAX NG validation no longer re-derives a shared definition on every path that reaches it, removing an exponential slowdown (#1811) by @gaborbernat.
  • RELAX NG validation no longer slows down with the square of the child count when many children each match one branch of a wide interleave, group or choice (#2048) by @gaborbernat.
  • RELAX NG validation now bounds the work each tag, attribute and text run costs by the schema's size, raising ValueError for content models too ambiguous to fit (#2027) by @gaborbernat.
  • RELAX NG validation now raises ValueError when a content model needs more alternatives than the schema's size allows, instead of using time and memory that grow exponentially (#1889) by @gaborbernat.
  • RelaxNG compiles very wide patterns, and raises RecursionError when references nest 400 levels deep without an element (#1901) by @gaborbernat.
  • XMLSchema now raises ValueError for an XSD schema whose xs:group references nest 400 levels or deeper, instead of crashing the interpreter during validation (#2086) by @gaborbernat.
  • XMLSchema now raises ValueError for an XSD schema whose references expand to more than 20,000 particles and attributes, instead of exponential validation time and memory (#1949) by @gaborbernat.
  • XMLSchema validation and compilation no longer slow down as a schema declaration carries more attributes or namespace declarations (#2109) by @gaborbernat.
  • parse_xml no longer takes time quadratic in the input size when a namespace URI is long (#1928) by @gaborbernat.
  • minify_js no longer slows down with the depth of parentheses or immediately invoked function wrappers around a script (#2005) by @gaborbernat.
  • minify_js no longer slows with the depth of nested redundant blocks and constant branches, and drops statements after a jump only up to the next declaration (#1952) by @gaborbernat.
  • canonicalize now raises ValueError when repeated namespace declarations outgrow the rest of the output, so a small document can no longer expand into gigabytes (#2214) by @gaborbernat.
  • form_data and field_value no longer rescan an optgroup's or fieldset's attributes for every option or legend, which made large pages quadratic (#1924) by @gaborbernat.
  • find and find_all with a regex, callable or list text filter now use memory linear in the document on deeply nested elements (#2068) by @gaborbernat.
  • to_markdown no longer crashes the interpreter on an XML document, a fragment, a shadow root or a detached inline element whose content ends in a line break, a no-break space or emphasized punctuation with no block element around it (#1784) by @gaborbernat.
  • A select mirrors its shown option into at most 16 selectedcontent elements. The rest keep the content the source gave them, so a page with many of them no longer builds a quadratic number of DOM nodes (#1816) by @gaborbernat.
  • A same-scheme reference with an encoded dot segment now resolves as a path under the base URL when its remainder has a colon in the first path segment, as the WHATWG URL standard specifies. Such references no longer use memory that grows quadratically with their length in Document.base_url(), meta_refresh() and link and structured-data extraction (#1826) by @gaborbernat.
  • A schema with many pattern facets now shares one size limit across all of them, so compiling it can no longer exhaust memory (#2092) by @gaborbernat.
  • A single matches() or closest() call with :disabled, :enabled, :read-write or :read-only now takes linear time inside disabled fieldset elements, including deeply nested ones (#2007) by @gaborbernat.
  • A stylesheet with many statement at-rules, such as @import, no longer takes quadratic time to parse in StyleSheet or computed_style (#1819) by @gaborbernat.
  • Absolute XPath paths in predicates no longer take quadratic time on deeply nested XML when the expression also reads a node-set variable or calls an extension function (#2021) by @gaborbernat.
  • Absolute XPath paths in predicates, and in XSLT select and test expressions, no longer take quadratic time on deeply nested XML (#1936) by @gaborbernat.
  • Adding nodes to a document one call at a time no longer stores a separate copy of each attribute value they share, keeping memory linear (#2008) by @gaborbernat.
  • An XPath expression that names many large regular expressions no longer keeps gigabytes of their compiled patterns allocated until it returns (#2038) by @gaborbernat.
  • An XPath location path that is only tested for emptiness, as a predicate, an operand of and or or, an argument of not() or boolean(), or the test of xsl:if or xsl:when, now stops at the first node it selects. Before, each candidate collected the whole axis, so evaluation time grew quadratically with the length of a sibling list (#1820) by @gaborbernat.
  • An <html> start tag in fragment input no longer sets attributes on the element returned as the fragment's context (#1910) by @gaborbernat.
  • Back-reference matching in XPath regular expressions now counts every compared character against the step budget, so patterns with long captured groups raise ValueError promptly (#1981) by @gaborbernat.
  • Bound the emphasis to_markdown reopens under deeply nested <b>, <i> or <s> elements, dropping inner runs of the same kind past the limit, so output stays proportional to the input (#1975) by @gaborbernat.
  • Bound the time sanitize, sanitize_node and migration.bleach.clean spend on deeply nested disallowed elements when the output must also be parse-stable, and escape a link nested in a link that follows an element that escapes to nothing. Past 32 levels, the output of sanitize_node, of sanitize on input that must be parse-stable, and of migration.bleach.clean can differ from before, and sanitize_node agrees with sanitize on such input (#1830) by @gaborbernat.
  • Bound the time and memory minify_css spends on nested @media blocks that repeat a prelude at every level. Blocks fuse only when at most seven blocks enclose them, so deeper same-query blocks stay separate (#1798) by @gaborbernat.
  • Building a tree with parse_into or walking SAX events no longer costs time and memory quadratic in the input when attributes are copied many times (#1885) by @gaborbernat.
  • CSS minification returns a stylesheet unchanged whenever its minified form would contain </style, so a minified <style> body can no longer end its element early (#1812) by @gaborbernat.
  • CSS selector queries, computed_style and rewrite no longer slow down quadratically with nesting depth when a selector uses a descendant combinator, :lang(), :dir() or :has() (#2193) by @gaborbernat.
  • Calling canonicalize on an element below the root no longer takes time quadratic in the number of inherited xml: attributes (#1976) by @gaborbernat.
  • Canonicalizing parsed XML with many namespace declarations no longer stalls canonicalize (#1884) by @gaborbernat.
  • Combining the xml:base attributes above a subtree in Canonical XML 1.1 took time that grew with the square of their nesting depth; it now grows with their total length (#1844) by @gaborbernat.
  • Compile a regular expression with many named groups in linear time: matches, replace, re:test and re:replace no longer compare each (?P<name>...) with every earlier name, which made a pattern with many named groups take quadratic time to compile (#1839) by @gaborbernat.
  • Compiling a RelaxNG or XMLSchema schema whose elements carry many attributes, and validating documents against it, no longer takes time quadratic in its size (#2130) by @gaborbernat.
  • Compiling a deeply nested XML Schema or RELAX NG schema no longer crashes worker threads with small stacks, including schemas that chain group references (#2095) by @gaborbernat.
  • Compiling an XML Schema where many simple types derive from one base with many facets now takes time and memory linear in the schema's size (#2043) by @gaborbernat.
  • Compiling and applying an XSLT stylesheet now takes time linear in its size instead of quadratic, so a large nested or attribute-heavy stylesheet no longer holds the process for seconds (#2111) by @gaborbernat.
  • Converting a list item nested inside another list item to Markdown no longer crashes the Python process (#2066) by @gaborbernat.
  • Converting a long internationalized host to punycode now takes time close to linear in its length, and a host that mapping lengthens past 16384 code points stays Unicode (#2016) by @gaborbernat.
  • Converting a long run of <br> elements in to_markdown now takes linear time; a block inside a link dropped by strip or convert ends the run (#2101) by @gaborbernat.
  • Copying a document or moving nodes between documents no longer uses memory that grows with the square of the input size (#1969) by @gaborbernat.
  • Copying or sanitizing a ShadowRoot now returns a DocumentFragment holding its children, not a shadow root (#1987) by @gaborbernat.
  • Deeply nested XSLT key lookups now raise RecursionError instead of crashing the interpreter (#1964) by @gaborbernat.
  • Deeply nested documents no longer expand into millions of nodes; formatting elements the depth limit cannot reopen are now dropped (#1951) by @gaborbernat.
  • Descendant :has() queries no longer take time quadratic in the nesting depth of a document, however it was built or edited (#1821) by @gaborbernat.
  • Escape the text of a raw-text node such as xmp or style when sanitize returns a parsed node as a string (#1914) by @gaborbernat.
  • Extract Atom type="xhtml" text in linear time when one element carries many namespace-prefixed attributes (#1804) by @gaborbernat.
  • Feeding IncrementalParser, Tokenizer or HTMLParser a character reference whose digits, or whose name characters past the longest entity name, never end no longer takes time quadratic in its length: the suspended reference resumes its scan where the last chunk ran out instead of starting over at its & (#1828) by @gaborbernat.
  • Find an attribute's source text in time linear in the attribute count while cleaning with clean; a start tag with many attributes no longer stalls it (#1795) by @gaborbernat.
  • Fix an out-of-bounds read in to_markdown for an emphasis element wrapping an image without alt text in Markdown.Images(mode="alt"); such an image now adds nothing to the output (#2107) by @gaborbernat.
  • Fix an out-of-bounds write through ElementView.getroottree().getroot() for elements in shadow trees and document fragments; the root is now the outermost element (#1912) by @gaborbernat.
  • Follow only the references the XSD cycle check covers when validating: XMLSchema.validate also walked a complexContent or simpleContent nested in an attribute group or a derivation, a type's second content child, and a group reference inside an xs:annotation, so a circular schema compiled and then overflowed the C stack. An annotation in an xs:choice no longer counts as an empty branch (#1786) by @gaborbernat.
  • Foreign <script> and <style> elements inside <svg> or <math>, and HTML <script> and <style> elements that were given element children through the DOM API, now supply only their own text children to json_ld, structured_data, dates and computed_style. Text inside an element child, or inside a nested one, no longer joins the outer block or sheet (#1832) by @gaborbernat.
  • HTML, sanitized HTML, minified HTML and canonical XML no longer repeat an unclosed formatting element's attributes without limit, so output stays linear in input size (#2035) by @gaborbernat.
  • Ignore a <base href> or feed xml:base that resolves to more than 2,048 characters, so extractors no longer slow down on long bases (#1933) by @gaborbernat.
  • Indentation in Html(layout=Indent()) stops at 64 nesting levels, so deeply nested documents no longer serialize to output quadratic in their size (#1919) by @gaborbernat.
  • Items that share one large itemref subtree no longer cost time quadratic in its size when microdata() or structured_data() reads them (#1989) by @gaborbernat.
  • Keep minify_css linear in the number of rules when a merged rule merges again into an earlier rule (#1934) by @gaborbernat.
  • Keep a calc() whose folded coefficient reaches the most negative 64-bit integer unfolded in minify_css instead of crashing with a division error or writing a wrong value (#1785) by @gaborbernat.
  • Keep the text of a RELAX NG include or externalRef target alive while its tree is copied into the schema, so compiling a multi-file schema no longer reads freed memory (#1792) by @gaborbernat.
  • Leave out Microdata and RDFa text properties nested more than 32 deep, instead of repeating their text at every level (#1938) by @gaborbernat.
  • Limit the bracket nesting linkify and LinkDetector follow in a URL to 32 levels so a run of links that each precede an unclosed bracket no longer takes quadratic time to scan (#1805) by @gaborbernat.
  • Limit the nested <time> and date-marked elements whose text dates scans to eight levels, which keeps the scanning time proportional to the page size on deeply nested markup. Deeper elements are dated from their datetime or title attribute only; their signal can change from time to text, or the date can be None with extensive_search=False (#1797) by @gaborbernat.
  • Linkify reads a written tel: URI's payload only up to the phone number length limit when phone detection is on (#1833) by @gaborbernat.
  • Links and rewrites no longer repeat work and memory for each copy of a reopened formatting element; rewrite_links calls its function once for those copies (#2059) by @gaborbernat.
  • List an option only for its nearest select in form_data and field_value, so nested selects and options cannot multiply the returned values (#1929) by @gaborbernat.
  • Loading a pickled document with deeply nested elements no longer takes time that grows with its node count times its depth (#1923) by @gaborbernat.
  • Long link targets, titles, languages and HTML attributes repeated in copies of an unclosed link or code element no longer multiply Markdown or text output; copies over the limit drop them (#1945) by @gaborbernat.
  • Make closest take linear time on deep XML trees, instead of quadratic time (#1984) by @gaborbernat.
  • Markdown export of emphasis around many empty quotes or preserved-white-space elements no longer takes quadratic time, and emphasis after punctuation followed by a long run of empty elements is written as an HTML tag (#2079) by @gaborbernat.
  • Markdown output escapes < in link and image titles and in bare link destinations, so a reader that rejects the link shows the text, not raw HTML (#2065) by @gaborbernat.
  • Matching CSS selectors or a class_ filter no longer takes quadratic time when a page has one long class or attribute value above, or repeated across, many elements (#2087) by @gaborbernat.
  • Matching a CSS selector with a very long chain of combinators raises RecursionError when the thread's stack cannot hold it, instead of crashing (#2205) by @gaborbernat.
  • Merge the attributes of repeated <html> and <body> start tags in time and memory linear in the attribute count, so a page with many such tags can no longer make parse take quadratic time or allocate quadratic memory (#1808) by @gaborbernat.
  • Microdata extraction no longer slows down sharply on an itemprop attribute that lists thousands of names (#2049) by @gaborbernat.
  • Microdata extraction now raises RecursionError past fixed limits on items and properties shared through itemref, instead of spending exponential or quadratic time (#2020) by @gaborbernat.
  • Minify JavaScript in linear time when parenthesized groups hold regex or template literals with parentheses, and reject await or yield in arrow parameters (#2085) by @gaborbernat.
  • Minify serialization of deeply nested XML-derived trees no longer takes quadratic time; rt, rp and optgroup end tags deeper than the parser's limit are kept (#2058) by @gaborbernat.
  • Minifying JavaScript no longer slows down on scripts with many nested unary operators (#1983) by @gaborbernat.
  • Minifying JavaScript that redeclares a catch parameter with var or reads arguments many times now takes time linear in the script length (#2067) by @gaborbernat.
  • Minifying JavaScript with deeply nested constant-false branches or unreachable statements that keep a declaration no longer takes time quadratic in the nesting depth (#2051) by @gaborbernat.
  • Minifying deeply stacked JavaScript chains no longer crashes the process; they raise nested too deeply, and some long scripts that minified before now fail the same way (#2069) by @gaborbernat.
  • Nested :nth-child(... of S) selectors no longer translate S once per use, and a selector whose XPath would pass 16,777,216 characters raises ExpressionError from css_to_xpath instead of building an unbounded expression (#1817) by @gaborbernat.
  • Parsing a select whose optgroup has many attributes and many option elements no longer takes time quadratic in the input size (#1818) by @gaborbernat.
  • Parsing a select with misnested formatting elements and option elements between them no longer takes time quadratic in the number of nodes under that select. When a select holds more than sixteen enabled selectedcontent elements, the clones go to the first sixteen targets in the order the select lists them, which can differ from the order used before (#1822) by @gaborbernat.
  • Parsing a formatting element with many attributes that the parser reopens many times now uses memory linear in the input; past a bound, reopened copies carry no attributes (#2070) by @gaborbernat.
  • Parsing an XPath function call now stops at the first malformed argument, so a rejected expression no longer corrupts heap memory before raising ValueError (#1870) by @gaborbernat.
  • Parsing and sanitizing HTML with many formatting elements now takes time linear in the size of the document (#1886) by @gaborbernat.
  • Parsing and sanitizing a MathML annotation-xml element with many attributes and many children no longer takes time quadratic in the input size. The parser reads the element's encoding attribute once, when the start tag is parsed, and the sanitizer reads it once per element rather than once per child (#1807) by @gaborbernat.
  • Parsing and sanitizing markup with many active formatting elements no longer takes time that grows with the square of the input size (#1941) by @gaborbernat.
  • Parsing reopens only the 16 innermost unclosed formatting elements per block and drops the outer ones, which bounds memory use on hostile markup (#2057) by @gaborbernat.
  • Parsing tables with text that alternates between two runs no longer slows down or uses excessive memory (#2033) by @gaborbernat.
  • Parsing, tokenizing, and xsl:key lookups stay fast when a document uses many attribute or key names that happen to collide; output is unchanged (#1843) by @gaborbernat.
  • Phone-number linking now runs in linear time on long text; the links found are unchanged (#2082) by @gaborbernat.
  • Positional selectors such as :first-of-type and :nth-child() no longer take time quadratic in the length of a long sibling list (#1947) by @gaborbernat.
  • Preceding-axis searches from deeply nested elements, including find, find_all, preceding and XPath preceding::, now take linear time instead of quadratic time (#1943) by @gaborbernat.
  • Prevent a double free when MutationObserver.take_records() or deliver() fails part-way through a batch, as it does on an attribute whose name is a lone surrogate. The failed drain now drops its batch, and a drain no longer reads observer state that take_records(), deliver() or disconnect() changes while a record is being built (#1790) by @gaborbernat.
  • Prevent an out-of-bounds read in the parser when malformed markup, nesting past the depth cap, or a foreign fragment context emptied its open-element stack (#1840) by @gaborbernat.
  • Prevent an out-of-bounds write in IncrementalParser when an ISO-2022-JP chunk ends on the escape byte that cuts a two-byte character short (#1791) by @gaborbernat.
  • Prevent an out-of-bounds write in minify_css when a background layer consists of a lone / (#1787) by @gaborbernat.
  • Prevent an out-of-bounds write when Markdown export closes emphasis after a stale hard line break, and keep converter text that was dropped (#1911) by @gaborbernat.
  • Prevent an out-of-bounds write when Markdown export wraps a short bold or italic run in a non-ASCII wrapper (#1788) by @gaborbernat.
  • RDFa vocab and prefix IRIs longer than 256 code points are now ignored, which keeps rdfa() memory bounded on untrusted pages (#1913) by @gaborbernat.
  • RELAX NG and XSD validation no longer keep a copy of each whitespace-normalized value until the call returns (#1918) by @gaborbernat.
  • RELAX NG schemas whose interleave branches overlap through a wildcard name, a <ref>, a mixed or a later combine="interleave" part now raise ValueError at compile time instead of compiling. Interleave checks on very large grammars raise ValueError once they exceed a fixed amount of work (#1799) by @gaborbernat.
  • RELAX NG schemas with a long xml:base over many references compile in linear time; a base URI over 8,192 characters now raises ValueError (#2054) by @gaborbernat.
  • RELAX NG schemas with overlapping attribute names in one group or interleave, or an anyName or nsName attribute outside oneOrMore or zeroOrMore, now raise ValueError when compiled (#2037) by @gaborbernat.
  • Raise UnicodeEncodeError when Node.encode would write U+000E, U+000F or U+001B under an ISO-2022 codec such as iso-2022-jp. Those characters switch the state of a reader's decoder, so markup holding one could be read differently from the markup that was serialized; etree.tostring writes the three as character references (#1813) by @gaborbernat.
  • Raise ValueError instead of crashing the interpreter when a stylesheet calls system-property(), function-available() or element-available() without an argument; a call with more than one is rejected too (#1782) by @gaborbernat.
  • Read a <tr> inside a table cell as that cell's content, and limit the cell text Node.tables() repeats for tables nested inside two or more other tables to 16,000,000 characters per call, so a page of deeply nested tables cannot expand into gigabytes of text (#1810) by @gaborbernat.
  • Read the feed-level Atom <author> once per feed instead of once per entry that inherits it, so feed no longer takes time and memory that grow with the product of the entry count and the size of that <author> (#1814) by @gaborbernat.
  • Reading assigned_slot, assigned_nodes() or flattened_children for every child or slot of a shadow tree no longer takes time quadratic in the size of the tree (#2004) by @gaborbernat.
  • Refuse an xsl:import or RELAX NG externalRef/include path longer than the platform path limit, even when it would normalize shorter, so a long href is rejected quickly (#1916) by @gaborbernat.
  • Reject JavaScript whose class extends clauses nest past the minifier's depth limit with ValueError instead of overflowing the C stack (#1867) by @gaborbernat.
  • Reject a script whose identifier holds a malformed \u escape or one for a code point a name cannot spell, and stop joining string literals whose \x or \u escape has no value, so minify_js never returns a str holding a code point past U+10FFFF (#1783) by @gaborbernat.
  • Removing elements with turbohtml.etree.strip_elements now takes time linear in the tree size, even when the tree is deeply nested (#1986) by @gaborbernat.
  • Resolve RDFa prefix declarations in time linear in the page: an element that declares a prefix no longer copies every mapping in scope, so many declaring elements under an ancestor with a large prefix no longer stall rdfa and structured_data (#1794) by @gaborbernat.
  • Resolve namespace prefixes and xml:base values in RSS, RDF and Atom feeds in linear time, so feed no longer slows down on feeds with many declarations (#2009) by @gaborbernat.
  • Resolve namespace prefixes in Atom XHTML content in one pass, so feed no longer slows down on large XHTML titles and content (#1953) by @gaborbernat.
  • SVG and MathML elements named like form controls or options no longer count as controls, so form submission and field values ignore them (#2077) by @gaborbernat.
  • Sanitizing a start tag with many attributes no longer takes quadratic time when removals are reported or callbacks are set; name checks now run before the attribute filter (#1930) by @gaborbernat.
  • Schema pattern checks in one validate call now share a step budget, so a pattern that runs for minutes raises ValueError instead (#2074) by @gaborbernat.
  • Schema patterns with nested repeats of an empty group now compile in bounded time, and some patterns the state limit refused now compile (#1944) by @gaborbernat.
  • Schemas with many pattern facets no longer take quadratic time to compile or validate, for XMLSchema and RelaxNG alike (#1926) by @gaborbernat.
  • Searching with a str or literal-regex text filter in find and find_all no longer takes quadratic time on deeply nested XML documents (#1841) by @gaborbernat.
  • Selector lists and stylesheets with many :has() arguments no longer take quadratic time on deeply nested trees (#1803) by @gaborbernat.
  • Selectors :disabled, :enabled, :read-write and :read-only now take linear time for controls inside a disabled fieldset, instead of growing quadratically with its size (#1917) by @gaborbernat.
  • Selectors with many :*-of-type pseudo-classes on a missing or unusual type name no longer rescan the compound for each one, and stop at the output limit promptly (#2117) by @gaborbernat.
  • Serialize XML trees in linear time when xlink: attributes inherit their namespace declaration from an ancestor (#1925) by @gaborbernat.
  • Serializing part of an XML tree no longer takes cubic time in the namespace declarations above it, and skips declarations whose prefix holds a colon (#2110) by @gaborbernat.
  • Stop :nth-child() and other An+B selectors crashing the interpreter near the int limits, and clamp An+B integers beyond that range instead of wrapping them (#1876) by @gaborbernat.
  • Stop minify_css from taking time quadratic in the length of a border, outline or column-rule value (#1921) by @gaborbernat.
  • Stop minify_css from taking time quadratic in the nesting depth of a CSS filter value's drop-shadow() and math functions (#1806) by @gaborbernat.
  • Stop select(), matches(), closest() and computed_style() crashing on a detached element when a selector looks at its parent through >, :root, :scope or an option's :disabled/:enabled (#1793) by @gaborbernat.
  • Stop structured_data() and schema validation from crashing the interpreter on a Document made by copy.copy, copy.deepcopy or sanitize_node (#2046) by @gaborbernat.
  • Stop chained sibling combinators inside :has(), such as :has(~ a ~ b), from multiplying query time with each link (#2202) by @gaborbernat.
  • Stop keeping an allowlisted <style> inside a kept <select>, which some parsers read as markup; drop comments in SVG or MathML <textarea> elements (#2036) by @gaborbernat.
  • Stop nested selector lists, :has() and :nth-child(of S) from multiplying match time with each nesting level, so matching stays linear in the stylesheet and the document depth (#2216) by @gaborbernat.
  • Table extraction now raises ValueError once spans and row padding add more than 4,000,000 cells to a call's grid, instead of allocating gigabytes (#1948) by @gaborbernat.
  • The XPath lang() function, also inside XSLT transforms, now runs in linear time on deeply nested documents and below elements with many attributes (#2094) by @gaborbernat.
  • The sanitize functions now raise RecursionError for a tree with more than 1,536 disallowed elements nested in one another, instead of taking quadratic time (#1960) by @gaborbernat.
  • Treat an xs:group particle that has no ref as matching no content in XMLSchema, instead of crashing the interpreter when a document reaches it (#1801) by @gaborbernat.
  • Treat the attribute as absent when Node.re() or Node.re_first() is called with attr= on a text node, processing instruction, doctype or other non-element node, instead of reading attribute storage that the node does not have, which could crash the interpreter (#1789) by @gaborbernat.
  • URL cleaning no longer crashes on a query or fragment key that holds an encoded NUL; such a key is kept unless another rule drops it (#1872) by @gaborbernat.
  • Validating an xs:all element that lacks a required member now reports that element's line, instead of a value read from unrelated memory (#2091) by @gaborbernat.
  • Validating an xs:all group no longer slows down with the square of its member and child counts. A name declared twice in one xs:all is now reported missing once (#1920) by @gaborbernat.
  • Validating an xs:all group now rejects a child element that appears more often than its declaration allows, including inside named groups and complex type extensions (#2012) by @gaborbernat.
  • Validating children against an ambiguous repeating XSD particle now takes linear time, and some valid children that such a particle rejected are now accepted (#2013) by @gaborbernat.
  • Validating many children against a repeating particle of an XSD XMLSchema now takes linear time and memory in the child count (#1979) by @gaborbernat.
  • Writing many attributes onto one element, through XSLT, Element.attrs or linkify(process_existing=True), now takes time linear in their number (#1879) by @gaborbernat.
  • XML Schema validation no longer allocates memory per element in proportion to its complex type's declarations, so large documents need far less memory (#2089) by @gaborbernat.
  • XML output keeps a processing instruction from ending early when a character XML cannot hold sits between its ? and > (#2019) by @gaborbernat.
  • XML serialization now raises ValueError when inherited namespace declarations would multiply the output, and Atom feeds omit them instead (#1937) by @gaborbernat.
  • XMLSchema validation no longer takes quadratic time when schema elements hold many children that declare nothing (#2113) by @gaborbernat.
  • XPath matches, replace, re:test and re:replace now count matching work against the evaluation's step budget, so expensive patterns raise ValueError instead of running for minutes (#2045) by @gaborbernat.
  • XPath string-join, replace, re:replace, str:replace and str:padding now raise ValueError when one evaluation adds more than 64 MiB to its strings, instead of allocating gigabytes (#2090) by @gaborbernat.
  • XPath and XSLT id() called once per node now run in linear time, and select only the first element in document order when several share an id (#2080) by @gaborbernat.
  • XPath steps from many context nodes along overlapping axes, such as following-sibling::p[1], now hold each node once and take linear time instead of quadratic (#2183) by @gaborbernat.
  • XPath string and node-set functions now raise ValueError once one call gathers more than 10 MiB of repeated element text, instead of running without limit (#1906) by @gaborbernat.
  • XPath unions and reverse-axis steps over long sibling lists now sort in linear time, whatever the document's shape (#1922) by @gaborbernat.
  • XPath unions, bound variables and reverse-axis steps over wide or deeply nested documents now finish in linear time, so large queries no longer stall (#1823) by @gaborbernat.
  • XSLT key() with a node-set as its second argument now returns each matching node once, in document order. It returned the matches once per argument node, so the result and its memory grew with the square of a document that repeated one key value (#1829) by @gaborbernat.
  • XSLT patterns that test prefixed attributes by name now take linear time on deeply nested source documents (#2132) by @gaborbernat.
  • XSLT transforms that put many attributes on one result element and then add literal children or namespaced attributes to it now run in linear time instead of quadratic (#2139) by @gaborbernat.
  • :dir() no longer takes quadratic time on pages with many elements under dir=auto ancestors or with deeply nested dir=auto elements (#2003) by @gaborbernat.
  • Element.form_data() now allocates the field name once per <select multiple> instead of once per selected option. Before, the memory of the result grew with the product of the name length and the number of selected options (#1796) by @gaborbernat.
  • Markdown.Tables(pad=True) keeps output proportional to the input, and a table whose cells cannot fund its alignment is written as plain pipe rows (#2084) by @gaborbernat.
  • Node.canonicalize() on parsed XML documents with long namespace URIs now takes time linear in the size of the document (#1946) by @gaborbernat.
  • Policy.media_hosts checks the host a browser loads from each media src, so a value with a hidden or misplaced authority no longer passes the allowlist (#2018) by @gaborbernat.
  • Query.find no longer takes quadratic time when it is called on many elements (#1882) by @gaborbernat.
  • Range content methods and common_ancestor_container no longer take time quadratic in the document size when the boundaries sit deep in the tree (#2104) by @gaborbernat.
  • XMLSchema and RelaxNG validation lists at most 1,000 errors and cuts element names longer than 64 characters in error paths (#1940) by @gaborbernat.
  • computed_style() caps the memory it keeps for :has() results per document, so large pages with many :has() rules no longer retain unbounded memory (#1950) by @gaborbernat.
  • microdata(), structured_data() and XSLT template matching no longer take quadratic time on crafted documents (#1942) by @gaborbernat.
  • minify_js() no longer crashes on huge guard lists, long operator groups or nested single-use functions; past a depth limit it leaves the remaining code in its original shape (#1898) by @gaborbernat.
  • minify_js no longer returns invalid JavaScript or the wrong value for a variable that a destructuring declaration re-binds (#2010) by @gaborbernat.
  • minify_js no longer returns invalid JavaScript, overflows the stack, or grows its output exponentially on some scripts that use destructuring patterns (#1868) by @gaborbernat.
  • minify_js no longer searches the statement after a declaration once per regex-initialized binding. Scripts with many such bindings in front of one long statement took time quadratic in their length (#1800) by @gaborbernat.
  • minify_js no longer slows down quadratically on long &&, || or ?? chains, so large scripts minify quickly (#1890) by @gaborbernat.
  • minify_js now keeps peak memory proportional to the script size when minifying long chains of concatenated string literals (#1873) by @gaborbernat.
  • minify_js now raises ValueError for an object shorthand property whose key is not an identifier, which is not valid JavaScript (#1809) by @gaborbernat.
  • minify_js now raises ValueError when a punctuator stands where an object, pattern or class property name, or a member name after ., ?. or new., belongs. A punctuator there used to repeat the text of an earlier token, so its output could grow with the square of the input size (#1815) by @gaborbernat.
  • rewrite() no longer scans open elements for end tags that match none of them, so unmatched closing tags cost linear time (#2218) by @gaborbernat.
  • rewrite() no longer turns markup the parser ignored or discarded into live elements when an edit changes a <frameset>, the markup around it, or an attribute the parser reads (#2209) by @gaborbernat.
  • xpath_path() now returns a path that selects the element it came from, even for tag names with XPath syntax or a namespace prefix (#2073) by @gaborbernat.
  • xsl:number level="any" without count now takes linear time when element names alternate in document order, with or without from (#1931) by @gaborbernat.
  • xsl:number no longer reads out of bounds or prints a wrong number when a stylesheet mixes default and pattern-based numbering (#2050) by @gaborbernat.
  • xsl:number now numbers deeply nested documents in linear time, and matches a prefixed count or from pattern once per instruction instead of once per number (#2178) by @gaborbernat.
  • xsl:number now takes linear time when several instructions with different or repeated count or from patterns, or alternating sibling names, number one run (#2001) by @gaborbernat.
  • xsl:number with a count or from pattern that reads current() now tests only the nodes it counts, instead of matching the pattern over the whole document for every number (#2129) by @gaborbernat.

Performance

Packaging

  • Every wheel now carries a PEP 770 CycloneDX SBOM in its .dist-info/sboms directory, written by python-sbom, which wraps meson-python and describes each release wheel again after its repair (#1667) by @gaborbernat.
  • The complexity regression tests now count the C loop steps that a -Dwork_steps=true build records instead of timing parses, so they no longer pass or fail with machine load. Release builds leave the option off and compile the counter out (#1845) by @gaborbernat.
  • The rewrite linear-time test now sweeps every attribute name, so its result no longer depends on the hash seed (#2212) by @gaborbernat.

🐍 PyPI release

📜 Full Changelog