diff --git a/app/xcf/xcf-load.c b/app/xcf/xcf-load.c index b431262621..82ef7e5f0b 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 14e82738f5..8da75a7145 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 4a2c053cde..9845725bae 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 = '?'; + } } - } }