Keep XMP file buffers in native state and release them at the file run boundary. Count registered namespaces and expanded metadata against the heap limit. Reset marked readers after updates and allow failed library setup to retry.
getProperty with an item path and getArrayItem gave an item with an xml:lang qualifier the
options 0. They now give PROP_HAS_QUALIFIERS and PROP_HAS_LANG, as a property with xml:lang has,
and docs/mcp.md says so.
- closeFile with XMPConst.CLOSE_UPDATE_SAFELY passes the flag to xmpWrite, which then writes only
through a temporary file; where none may be made it throws and leaves the sidecar and the packet
as they are.
- On Unix the temporary file is created with mode 0600 and takes the sidecar's permission bits
after the packet is written.
- canPutXMP and putXMP check again that the file is open for update after converting the packet
argument, since a toString may close it.
- Path arguments are converted once, so a toString that changes between calls cannot mix two
paths.
- setLocalizedText moves an existing x-default item to the front.
- A second ExternalObject install is refused and keeps the registered namespaces.
- Text beside rdf:Description elements or their properties makes a packet malformed.
- Properties read from a packet share one copy of each namespace URI, and reading stops once the
properties exceed the script heap.
- A value with qualifiers in the rdf:value form gives the text and options of its rdf:value, and
an empty property element whose attributes are fields is a structure.
- serialize() and reading refuse a value that would be written with more than 1,024 attributes or
namespace declarations in scope at one element.
- find_packet treats packet markers inside CDATA sections and comments as text, and passes over a
packet that is not UTF-8 for the next one. A section that holds a trailer and then a start does
not hide that start, and each marker search starts where the last one stopped, so the scan
reads the bytes about once.
- An rdf:Alt item with xml:lang="" has no language, so its array is not a language alternative;
the empty attribute is written back as it was.
- The rdf:about value counts toward the parse budget, also in a packet with no properties.
- docs/mcp.md says that the prefix limit applies to a namespace being registered.
- The round-trip property test generates valid packets, the retry test closes the same XMPFile
again after a failed write, and the heap-limit test requires a heap-limit error and a change
that goes through.
- A packet starts at a <?xpacket begin= whose header holds the wrapper
id W5M0MpCehiHzreSzNTczkc9d within 256 bytes, so the same text inside
a value, such as in a CDATA section, does not restart the scan.
- setLocalizedText adds a new array in the same change that sets its
item, so a call that stops at the heap limit leaves no empty array.
- The 15 XMP error messages are English only; their translations are
left to storytold/craft-i18n, as AGENTS.md asks of feature pull
requests.
Tests: packets_are_found_in_file_bytes and
localized_text_past_the_heap_limit_adds_no_array in
crates/js/src/xmp_tests.rs. Docs: docs/mcp.md.
- setProperty with an array item path, such as list[1], and any
option throws that the value is not available yet instead of setting
the item and leaving the option out.
- getLocalizedText and setLocalizedText throw that the array is not a
language alternative array for an rdf:Alt with an item that has no
xml:lang.
Tests: bad_arguments_and_unbuilt_members_throw in
crates/js/src/xmp_tests.rs.
- XMPFile's methods refuse an object the XMPFile constructor did not
make, so a plain object or one made from XMPFile.prototype with
properties of the same names is not read or written as a file.
- setLocalizedText for x-default also changes the items that had the
text of the x-default item.
Tests: a_script_cannot_change_the_state_of_an_xmp_file in
crates/engine/src/tests/script_xmp.rs and
localized_text_for_x_default_changes_the_items_that_matched_it in
crates/js/src/xmp_tests.rs.
An XMPFile kept its path, open flags and pending packet in writable,
configurable properties, so a script could assign a packet to a file
opened for reading and closeFile wrote it without checking the update
flag or reading the packet.
- The properties holding an XMPFile's state are not writable,
enumerable or configurable, and the pending packet is one of them from
the start.
- The XMPMeta docs say that only the namespaces a packet's names use
are registered, which is what reading a packet does.
Test: a_script_cannot_change_the_state_of_an_xmp_file in
crates/engine/src/tests/script_xmp.rs. Docs: docs/mcp.md.
setProperty and the other property members took a path in the RDF or
XML namespace, and serialize() wrote a packet that XMPMeta could not
read back. Such a path now throws "... is not a valid property name".
Test: rdf_and_xml_namespaces_hold_no_properties 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.
- 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.