Skip to content

Conversation

@aschempp
Copy link
Member

@aschempp aschempp commented Nov 4, 2025

I tried parsing an image that resulted in an exception message Contao\Image\Metadata\XmpFormat::parseValue(): Argument #1 ($namespace) must be of type string, null given, because the value for $attr->namespaceURI was null. Not sure how that can happen, and no idea how to write a test for that, but I think the library should rather ignore these values than throw an exception?

@ausi
Copy link
Member

ausi commented Nov 4, 2025

Wouldn’t it be better to fallback to the xmp or rdf namespace? Can you send me the image that fails?

@ausi
Copy link
Member

ausi commented Nov 6, 2025

Having some attributes without a namespace is actually valid, but deprecated, see https://www.w3.org/TR/REC-rdf-syntax/#eventterm-attribute-URI so we should properly support that.

Comment on lines +187 to +189
if ($attr->namespaceURI && $attr->localName) {
$metadata[] = $this->parseValue($attr->namespaceURI, $attr->localName, $attr->value);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ($attr->namespaceURI && $attr->localName) {
$metadata[] = $this->parseValue($attr->namespaceURI, $attr->localName, $attr->value);
}
$metadata[] = $this->parseValue($attr->namespaceURI ?? $desc->namespaceURI, $attr->localName, $attr->value);

Comment on lines -192 to +196
$metadata[] = $this->parseValue($node->namespaceURI, $node->localName, $node);
if ($node->namespaceURI && $node->localName) {
$metadata[] = $this->parseValue($node->namespaceURI, $node->localName, $node);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be reverted as nodes without namespaces are not supported.

@ausi
Copy link
Member

ausi commented Nov 6, 2025

While testing with your image I noticed that a broken XMP metadata results in the image having no metadata at all. We should probably fix that so the valid metadata parts are still shown correctly.

@ausi ausi self-assigned this Nov 6, 2025
@ausi ausi added the bug label Nov 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants