Dinu Gherman reports:
A long transform attribute could make "convertTransform()" take time
quadratic in its length: each pair of brackets rebuilt the whole string, and
the result was checked only afterwards, so 2 MB of brackets, which a 3 KB .svgz
file holds, kept svg2rlg() busy for minutes (CWE-407, GHSA-43qg-v5jj-vw5c). It
is read in one pass now, with the same result. Thanks to @lanjianchun for the
report.
An <image> that refers to a fragment of the document, with
href="#id", was rendered again without the checks that <use> has had
since 2.3.1: a cycle, such as an <svg> that contains an <image>
that refers to it, ended in RecursionError, and a few <image> elements
that refer to each other, each level to the one before it twice, took time that
doubled with every level, so that 2 KB took hours (CWE-400, CWE-674,
GHSA-cmj4-5g24-pp37, reported again as GHSA-4fr5-v6hm-mwjg). A cycle is now
skipped and an error is logged, and all <image> targets count against the
same budgets as <use> (MAX_USE_EXPANSIONS, MAX_USE_CLONED_ELEMENTS). An
<image> that refers to an element that is not defined yet is skipped too,
and not an AttributeError. Thanks to @GeniusKangaroo and @john-lawniczak for
the reports.
An image embedded as a data:image/png or data:image/jpeg URI was
opened by Pillow with the decoder chosen from its bytes, not from its label, so
a PostScript file made it run Ghostscript, where that is installed, when the
PDF was drawn (CWE-20, CWE-94, GHSA-h5r7-mh88-vjm4). Such an image is now
decoded as a PNG or a JPEG only (DATA_URI_IMAGE_FORMATS), and anything else is
refused with the UnidentifiedImageError that data that is not an image already
got. Thanks to @superbot-helper for the report.