mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-03 17:33:25 +00:00
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.
This commit is contained in:
parent
a3f4c50b3e
commit
e5a669bdfc
3 changed files with 23 additions and 18 deletions
|
@ -321,7 +321,9 @@ xcf_load_image (Gimp *gimp,
|
||||||
"gimp-metadata");
|
"gimp-metadata");
|
||||||
if (parasite)
|
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)
|
if (has_metadata)
|
||||||
{
|
{
|
||||||
|
@ -329,6 +331,14 @@ xcf_load_image (Gimp *gimp,
|
||||||
"has both 'gimp-image-metadata' and 'gimp-metadata' "
|
"has both 'gimp-image-metadata' and 'gimp-metadata' "
|
||||||
"parasites, dropping old 'gimp-metadata'\n");
|
"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
|
else
|
||||||
{
|
{
|
||||||
GimpMetadata *metadata = gimp_image_get_metadata (image);
|
GimpMetadata *metadata = gimp_image_get_metadata (image);
|
||||||
|
@ -340,8 +350,8 @@ xcf_load_image (Gimp *gimp,
|
||||||
metadata = gimp_metadata_new ();
|
metadata = gimp_metadata_new ();
|
||||||
|
|
||||||
if (! gimp_metadata_set_from_xmp (metadata,
|
if (! gimp_metadata_set_from_xmp (metadata,
|
||||||
gimp_parasite_data (parasite),
|
(const guint8 *) xmp_data + 10,
|
||||||
gimp_parasite_data_size (parasite),
|
xmp_length - 10,
|
||||||
&my_error))
|
&my_error))
|
||||||
{
|
{
|
||||||
gimp_message (gimp, G_OBJECT (info->progress),
|
gimp_message (gimp, G_OBJECT (info->progress),
|
||||||
|
|
|
@ -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 (xmp_data_length > 0, FALSE);
|
||||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||||
|
|
||||||
xmp_data += 10;
|
|
||||||
xmp_data_length -= 10;
|
|
||||||
|
|
||||||
xmp_metadata = gimp_metadata_new ();
|
xmp_metadata = gimp_metadata_new ();
|
||||||
|
|
||||||
if (! gexiv2_metadata_open_buf (xmp_metadata,
|
if (! gexiv2_metadata_open_buf (xmp_metadata,
|
||||||
|
|
|
@ -361,16 +361,14 @@ load_image (const gchar *filename,
|
||||||
xmp_data = exr_loader_get_xmp (loader, &xmp_size);
|
xmp_data = exr_loader_get_xmp (loader, &xmp_size);
|
||||||
if (xmp_data)
|
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,
|
if (gimp_metadata_set_from_xmp (metadata,
|
||||||
xmp_data - 10,
|
xmp_data,
|
||||||
xmp_size + 10,
|
xmp_size,
|
||||||
NULL))
|
NULL))
|
||||||
{
|
{
|
||||||
have_metadata = TRUE;
|
have_metadata = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (xmp_data);
|
g_free (xmp_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -407,13 +405,13 @@ static void
|
||||||
exr_load_sanitize_comment (gchar *comment)
|
exr_load_sanitize_comment (gchar *comment)
|
||||||
{
|
{
|
||||||
if (! g_utf8_validate (comment, -1, NULL))
|
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'))
|
gchar *c;
|
||||||
*c = '?';
|
|
||||||
|
for (c = comment; *c; c++)
|
||||||
|
{
|
||||||
|
if (*c > 126 || (*c < 32 && *c != '\t' && *c != '\n' && *c != '\r'))
|
||||||
|
*c = '?';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue