[gimp] libgimpbase: fix gimp_metadata_set_from_xmp() to really expect XMP
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] libgimpbase: fix gimp_metadata_set_from_xmp() to really expect XMP
- Date: Fri, 22 Apr 2016 20:51:41 +0000 (UTC)
commit e5a669bdfc7cebfaa48879bc6ee4e65bea10f71a
Author: Michael Natterer <mitch gimp org>
Date: Fri Apr 22 22:49:06 2016 +0200
libgimpbase: fix gimp_metadata_set_from_xmp() to really expect XMP
Don't skip the first 10 bytes. That code was there to skip the magic
"GIMP_XMP_1" of the old "gimp-metadata" parasite. Instead, properly
check for that magic in xcf_load_image() and pass only the actual XMP
to gimp_metadata_set_from_xmp(). Also remove the +10 hack in file-exr.
app/xcf/xcf-load.c | 16 +++++++++++++---
libgimpbase/gimpmetadata.c | 3 ---
plug-ins/file-exr/file-exr.c | 22 ++++++++++------------
3 files changed, 23 insertions(+), 18 deletions(-)
---
diff --git a/app/xcf/xcf-load.c b/app/xcf/xcf-load.c
index b431262..82ef7e5 100644
--- a/app/xcf/xcf-load.c
+++ b/app/xcf/xcf-load.c
@@ -321,7 +321,9 @@ xcf_load_image (Gimp *gimp,
"gimp-metadata");
if (parasite)
{
- GimpImagePrivate *private = GIMP_IMAGE_GET_PRIVATE (image);
+ GimpImagePrivate *private = GIMP_IMAGE_GET_PRIVATE (image);
+ const gchar *xmp_data = gimp_parasite_data (parasite);
+ gint xmp_length = gimp_parasite_data_size (parasite);
if (has_metadata)
{
@@ -329,6 +331,14 @@ xcf_load_image (Gimp *gimp,
"has both 'gimp-image-metadata' and 'gimp-metadata' "
"parasites, dropping old 'gimp-metadata'\n");
}
+ else if (xmp_length < 14 ||
+ strncmp (xmp_data, "GIMP_XMP_1", 10) != 0)
+ {
+ gimp_message (gimp, G_OBJECT (info->progress),
+ GIMP_MESSAGE_WARNING,
+ _("Corrupt 'gimp-metadata' parasite discovered.\n"
+ "XMP data could not be migrated."));
+ }
else
{
GimpMetadata *metadata = gimp_image_get_metadata (image);
@@ -340,8 +350,8 @@ xcf_load_image (Gimp *gimp,
metadata = gimp_metadata_new ();
if (! gimp_metadata_set_from_xmp (metadata,
- gimp_parasite_data (parasite),
- gimp_parasite_data_size (parasite),
+ (const guint8 *) xmp_data + 10,
+ xmp_length - 10,
&my_error))
{
gimp_message (gimp, G_OBJECT (info->progress),
diff --git a/libgimpbase/gimpmetadata.c b/libgimpbase/gimpmetadata.c
index 14e8273..8da75a7 100644
--- a/libgimpbase/gimpmetadata.c
+++ b/libgimpbase/gimpmetadata.c
@@ -694,9 +694,6 @@ gimp_metadata_set_from_xmp (GimpMetadata *metadata,
g_return_val_if_fail (xmp_data_length > 0, FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- xmp_data += 10;
- xmp_data_length -= 10;
-
xmp_metadata = gimp_metadata_new ();
if (! gexiv2_metadata_open_buf (xmp_metadata,
diff --git a/plug-ins/file-exr/file-exr.c b/plug-ins/file-exr/file-exr.c
index 4a2c053..9845725 100644
--- a/plug-ins/file-exr/file-exr.c
+++ b/plug-ins/file-exr/file-exr.c
@@ -361,16 +361,14 @@ load_image (const gchar *filename,
xmp_data = exr_loader_get_xmp (loader, &xmp_size);
if (xmp_data)
{
- // FIXME:
- // gimp_metadata_set_from_xmp skips the first 10 bytes.
- // working around that like this might not be the right thing to do!
if (gimp_metadata_set_from_xmp (metadata,
- xmp_data - 10,
- xmp_size + 10,
+ xmp_data,
+ xmp_size,
NULL))
{
have_metadata = TRUE;
}
+
g_free (xmp_data);
}
@@ -407,13 +405,13 @@ static void
exr_load_sanitize_comment (gchar *comment)
{
if (! g_utf8_validate (comment, -1, NULL))
- {
- gchar *c;
-
- for (c = comment; *c; c++)
{
- if (*c > 126 || (*c < 32 && *c != '\t' && *c != '\n' && *c != '\r'))
- *c = '?';
+ gchar *c;
+
+ for (c = comment; *c; c++)
+ {
+ if (*c > 126 || (*c < 32 && *c != '\t' && *c != '\n' && *c != '\r'))
+ *c = '?';
+ }
}
- }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]