Ensure Electron support for images with XMP metadata #4451

This commit is contained in:
Lovell Fuller 2025-09-12 12:33:59 +01:00
parent 23a0e81d98
commit d8686e7c64
2 changed files with 4 additions and 1 deletions

View File

@ -16,6 +16,9 @@ slug: changelog/v0.34.4
* Ensure `unlimited` flag is passed upstream when reading TIFF images. * Ensure `unlimited` flag is passed upstream when reading TIFF images.
[#4446](https://github.com/lovell/sharp/issues/4446) [#4446](https://github.com/lovell/sharp/issues/4446)
* Support Electron memory cage when reading XMP metadata (regression in 0.34.3).
[#4451](https://github.com/lovell/sharp/issues/4451)
* Add sharp-libvips rpath for yarn v5 support. * Add sharp-libvips rpath for yarn v5 support.
[#4452](https://github.com/lovell/sharp/pull/4452) [#4452](https://github.com/lovell/sharp/pull/4452)
[@arcanis](https://github.com/arcanis) [@arcanis](https://github.com/arcanis)

View File

@ -261,11 +261,11 @@ class MetadataWorker : public Napi::AsyncWorker {
info.Set("iptc", Napi::Buffer<char>::NewOrCopy(env, baton->iptc, baton->iptcLength, sharp::FreeCallback)); info.Set("iptc", Napi::Buffer<char>::NewOrCopy(env, baton->iptc, baton->iptcLength, sharp::FreeCallback));
} }
if (baton->xmpLength > 0) { if (baton->xmpLength > 0) {
info.Set("xmp", Napi::Buffer<char>::NewOrCopy(env, baton->xmp, baton->xmpLength, sharp::FreeCallback));
if (g_utf8_validate(static_cast<char const *>(baton->xmp), baton->xmpLength, nullptr)) { if (g_utf8_validate(static_cast<char const *>(baton->xmp), baton->xmpLength, nullptr)) {
info.Set("xmpAsString", info.Set("xmpAsString",
Napi::String::New(env, static_cast<char const *>(baton->xmp), baton->xmpLength)); Napi::String::New(env, static_cast<char const *>(baton->xmp), baton->xmpLength));
} }
info.Set("xmp", Napi::Buffer<char>::NewOrCopy(env, baton->xmp, baton->xmpLength, sharp::FreeCallback));
} }
if (baton->tifftagPhotoshopLength > 0) { if (baton->tifftagPhotoshopLength > 0) {
info.Set("tifftagPhotoshop", info.Set("tifftagPhotoshop",