closeFile() writes a sidecar through a new temporary file and renames it
over the sidecar, so a 0600 sidecar became 0644 under a 022 umask. The
temporary file now takes the sidecar's permission bits before the
rename, as File.copy does for its target.
Test: a_replaced_sidecar_keeps_its_permissions (Unix only) in
crates/engine/src/tests/script_xmp.rs.
A property holding text next to its rdf:Bag, rdf:Seq or rdf:Alt was
read as an array of simple items, and serialize() dropped the text.
Such a property is now kept as the XML it was written in.
Test: text_beside_an_array_is_kept in crates/js/src/xmp_tests.rs.
A structure or qualifier whose element or attribute used a prefix that
nothing declared was read and then serialized with the prefix unbound.
Such a packet is now refused as not well-formed XMP.
Test: namespaces_inside_kept_values_are_registered in
crates/js/src/xmp_tests.rs.
A namespace declared only inside a structure, an array of structures or
on a qualifier was not registered when the packet was read, so
XMPMeta.getNamespacePrefix gave undefined for it. Reading a value that
is kept as it was written now registers the namespaces its element and
attribute names use, other than RDF and XML.
Test: namespaces_inside_kept_values_are_registered in
crates/js/src/xmp_tests.rs.
- setLocalizedText reads its generic language argument. With no item in
the specific language and exactly one item in the generic language
or a variant of it, that item changes, as the XMP Toolkit SDK's
SetLocalizedText does (XMPCore/source/XMPMeta-GetSet.cpp); with
several, the specific language is added.
- A packet read from rdf:RDF alone could hold a value nested 64
elements deep that serialize() then wrote under x:xmpmeta, 65 deep,
so the written packet did not read back. A value is now measured as
deep as serialize() writes it, and one past 64 elements throws when
the packet is read.
Tests: localized_text_updates_a_single_generic_language_item and
deeply_nested_values_read_back_after_serializing in
crates/js/src/xmp_tests.rs. Docs: docs/mcp.md.
XMPMeta.registerNamespace and packets that declare namespaces could add
up to 4,096 namespaces of any length, held outside the script heap.
- A namespace URI over 1,024 bytes and a prefix over 128 bytes, the
`_n_` suffix included, throw "the XMP data is too large".
- The registered namespaces hold at most 1 MiB together; a namespace
past that throws the same error and is not registered.
- Reading a packet takes fuel for the namespaces it copies.
- Error messages hold at most the first 200 characters of a name,
path, value or namespace the script gave.
Tests: namespace_lengths_and_the_registry_budget_are_bounded,
long_namespaces_from_scripts_and_packets_are_refused and
error_messages_hold_a_bounded_part_of_the_script_text in
crates/js/src/xmp_tests.rs. Docs: docs/mcp.md.
new ExternalObject("lib:AdobeXMPScript") defines XMPMeta, XMPFile and
XMPConst in the script engine; any other library name throws and no
native library is loaded.
- XMPMeta reads a packet string and serializes one, with or without the
packet wrapper: simple properties, arrays of simple items, language
alternatives and namespace registration and lookup. Structures and
values with qualifiers are kept as they were written.
- XMPFile reads and writes only where File may. A .xmp sidecar opened
for update takes putXMP, and closeFile writes it through a temporary
file in the same folder when the script may write there; other files
are scanned for their packet and are read only. File's 8 MiB limit
applies before reading.
- Packets are parsed with craft-xml: a document type declaration, an
undefined entity, nesting over 64 levels and a packet over 8 MiB are
refused with an error.
- Members not built yet (iterators, structure fields, qualifiers,
aliases, sorting, byte-array packets, XMPFile.getFormatInfo) throw
that they are not available yet.
The XMPConst flag values follow the public XMP Toolkit SDK header
XMP_Const.h. Tests: crates/js/src/xmp_tests.rs, with fuzz cases for the
packet parser and scanner, and crates/engine/src/tests/script_xmp.rs.
Docs: docs/mcp.md and docs/target-app-parity.md.
A color a library pattern's art brings now skips the library's numbered
names while the pattern is imported, instead of being renamed after the
import. The rename also rewrote every other paint in the document linked
to the name the import first gave, such as art still linked to a deleted
"Ink 2", so adding the pattern changed that art. Now the names are held
with placeholder swatches during the import and removed afterwards, and
links that were already in the document stay as they were.
A pattern whose art brings both "Ink" and the library's "Ink 2" keeps the
library's "Ink 2" under its own name when the document gives "Ink"
another color, and the library's "Ink" takes the next free name. A library
pattern with a numbered name, such as "Tiles 2", keeps that name when the
document does not use it.