mirror of https://github.com/GNOME/gimp.git
plug-ins/common/gifload.c (DoExtension) UTF-8 validate the comment before
2003-02-10 Sven Neumann <sven@gimp.org> * plug-ins/common/gifload.c (DoExtension) * plug-ins/common/jpeg.c (load_image): UTF-8 validate the comment before setting it as a parasite.
This commit is contained in:
parent
3441b94de7
commit
7b9f7e3f2c
|
@ -1,3 +1,9 @@
|
|||
2003-02-10 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* plug-ins/common/gifload.c (DoExtension)
|
||||
* plug-ins/common/jpeg.c (load_image): UTF-8 validate the comment
|
||||
before setting it as a parasite.
|
||||
|
||||
2003-02-10 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* plug-ins/script-fu/scripts/distress_selection.scm
|
||||
|
|
|
@ -525,13 +525,15 @@ DoExtension (FILE *fd,
|
|||
while (GetDataBlock (fd, (unsigned char *) buf) > 0)
|
||||
{
|
||||
#ifdef FACEHUGGERS
|
||||
if (comment_parasite != NULL)
|
||||
{
|
||||
gimp_parasite_free (comment_parasite);
|
||||
}
|
||||
|
||||
comment_parasite = gimp_parasite_new ("gimp-comment",GIMP_PARASITE_PERSISTENT,
|
||||
strlen(buf)+1, (void*)buf);
|
||||
if (!g_utf8_validate (buf, -1, NULL))
|
||||
continue;
|
||||
|
||||
if (comment_parasite)
|
||||
gimp_parasite_free (comment_parasite);
|
||||
|
||||
comment_parasite = gimp_parasite_new ("gimp-comment",
|
||||
GIMP_PARASITE_PERSISTENT,
|
||||
strlen(buf) + 1, buf);
|
||||
#else
|
||||
if (showComment)
|
||||
g_print ("GIF: gif comment: %s\n", buf);
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
* jpeg parameters (quaility, smoothing, compression and progressive)
|
||||
* are attached to the image as a parasite. This allows the
|
||||
* parameters to remain consistent between saves. I was not able to
|
||||
* figure out how to determine the quaility, smoothing or compression
|
||||
* figure out how to determine the quality, smoothing or compression
|
||||
* values of an image as it is being loaded, but the code is there to
|
||||
* support it if anyone knows how. Progressive mode is a method of
|
||||
* saving the image such that as a browser (or other app supporting
|
||||
|
@ -696,9 +696,9 @@ my_error_exit (j_common_ptr cinfo)
|
|||
}
|
||||
|
||||
static gint32
|
||||
load_image (gchar *filename,
|
||||
load_image (gchar *filename,
|
||||
GimpRunMode runmode,
|
||||
gboolean preview)
|
||||
gboolean preview)
|
||||
{
|
||||
GimpPixelRgn pixel_rgn;
|
||||
GimpDrawable *drawable;
|
||||
|
@ -775,18 +775,20 @@ load_image (gchar *filename,
|
|||
if (!preview)
|
||||
{
|
||||
/* if we had any comments then make a parasite for them */
|
||||
if (local_image_comments && local_image_comments->len)
|
||||
if (local_image_comments && local_image_comments->len)
|
||||
{
|
||||
gchar *string = local_image_comments->str;
|
||||
gchar *comment = local_image_comments->str;
|
||||
|
||||
g_string_free (local_image_comments, FALSE);
|
||||
|
||||
local_image_comments = NULL;
|
||||
comment_parasite = gimp_parasite_new ("gimp-comment",
|
||||
GIMP_PARASITE_PERSISTENT,
|
||||
strlen (string) + 1, string);
|
||||
}
|
||||
else
|
||||
{
|
||||
comment_parasite = NULL;
|
||||
|
||||
if (g_utf8_validate (comment, -1, NULL))
|
||||
comment_parasite = gimp_parasite_new ("gimp-comment",
|
||||
GIMP_PARASITE_PERSISTENT,
|
||||
strlen (comment) + 1,
|
||||
comment);
|
||||
g_free (comment);
|
||||
}
|
||||
|
||||
/* Do not attach the "jpeg-save-options" parasite to the image
|
||||
|
@ -1054,6 +1056,8 @@ load_image (gchar *filename,
|
|||
{
|
||||
gimp_image_parasite_attach (image_ID, comment_parasite);
|
||||
gimp_parasite_free (comment_parasite);
|
||||
|
||||
comment_parasite = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
* jpeg parameters (quaility, smoothing, compression and progressive)
|
||||
* are attached to the image as a parasite. This allows the
|
||||
* parameters to remain consistent between saves. I was not able to
|
||||
* figure out how to determine the quaility, smoothing or compression
|
||||
* figure out how to determine the quality, smoothing or compression
|
||||
* values of an image as it is being loaded, but the code is there to
|
||||
* support it if anyone knows how. Progressive mode is a method of
|
||||
* saving the image such that as a browser (or other app supporting
|
||||
|
@ -696,9 +696,9 @@ my_error_exit (j_common_ptr cinfo)
|
|||
}
|
||||
|
||||
static gint32
|
||||
load_image (gchar *filename,
|
||||
load_image (gchar *filename,
|
||||
GimpRunMode runmode,
|
||||
gboolean preview)
|
||||
gboolean preview)
|
||||
{
|
||||
GimpPixelRgn pixel_rgn;
|
||||
GimpDrawable *drawable;
|
||||
|
@ -775,18 +775,20 @@ load_image (gchar *filename,
|
|||
if (!preview)
|
||||
{
|
||||
/* if we had any comments then make a parasite for them */
|
||||
if (local_image_comments && local_image_comments->len)
|
||||
if (local_image_comments && local_image_comments->len)
|
||||
{
|
||||
gchar *string = local_image_comments->str;
|
||||
gchar *comment = local_image_comments->str;
|
||||
|
||||
g_string_free (local_image_comments, FALSE);
|
||||
|
||||
local_image_comments = NULL;
|
||||
comment_parasite = gimp_parasite_new ("gimp-comment",
|
||||
GIMP_PARASITE_PERSISTENT,
|
||||
strlen (string) + 1, string);
|
||||
}
|
||||
else
|
||||
{
|
||||
comment_parasite = NULL;
|
||||
|
||||
if (g_utf8_validate (comment, -1, NULL))
|
||||
comment_parasite = gimp_parasite_new ("gimp-comment",
|
||||
GIMP_PARASITE_PERSISTENT,
|
||||
strlen (comment) + 1,
|
||||
comment);
|
||||
g_free (comment);
|
||||
}
|
||||
|
||||
/* Do not attach the "jpeg-save-options" parasite to the image
|
||||
|
@ -1054,6 +1056,8 @@ load_image (gchar *filename,
|
|||
{
|
||||
gimp_image_parasite_attach (image_ID, comment_parasite);
|
||||
gimp_parasite_free (comment_parasite);
|
||||
|
||||
comment_parasite = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
* jpeg parameters (quaility, smoothing, compression and progressive)
|
||||
* are attached to the image as a parasite. This allows the
|
||||
* parameters to remain consistent between saves. I was not able to
|
||||
* figure out how to determine the quaility, smoothing or compression
|
||||
* figure out how to determine the quality, smoothing or compression
|
||||
* values of an image as it is being loaded, but the code is there to
|
||||
* support it if anyone knows how. Progressive mode is a method of
|
||||
* saving the image such that as a browser (or other app supporting
|
||||
|
@ -696,9 +696,9 @@ my_error_exit (j_common_ptr cinfo)
|
|||
}
|
||||
|
||||
static gint32
|
||||
load_image (gchar *filename,
|
||||
load_image (gchar *filename,
|
||||
GimpRunMode runmode,
|
||||
gboolean preview)
|
||||
gboolean preview)
|
||||
{
|
||||
GimpPixelRgn pixel_rgn;
|
||||
GimpDrawable *drawable;
|
||||
|
@ -775,18 +775,20 @@ load_image (gchar *filename,
|
|||
if (!preview)
|
||||
{
|
||||
/* if we had any comments then make a parasite for them */
|
||||
if (local_image_comments && local_image_comments->len)
|
||||
if (local_image_comments && local_image_comments->len)
|
||||
{
|
||||
gchar *string = local_image_comments->str;
|
||||
gchar *comment = local_image_comments->str;
|
||||
|
||||
g_string_free (local_image_comments, FALSE);
|
||||
|
||||
local_image_comments = NULL;
|
||||
comment_parasite = gimp_parasite_new ("gimp-comment",
|
||||
GIMP_PARASITE_PERSISTENT,
|
||||
strlen (string) + 1, string);
|
||||
}
|
||||
else
|
||||
{
|
||||
comment_parasite = NULL;
|
||||
|
||||
if (g_utf8_validate (comment, -1, NULL))
|
||||
comment_parasite = gimp_parasite_new ("gimp-comment",
|
||||
GIMP_PARASITE_PERSISTENT,
|
||||
strlen (comment) + 1,
|
||||
comment);
|
||||
g_free (comment);
|
||||
}
|
||||
|
||||
/* Do not attach the "jpeg-save-options" parasite to the image
|
||||
|
@ -1054,6 +1056,8 @@ load_image (gchar *filename,
|
|||
{
|
||||
gimp_image_parasite_attach (image_ID, comment_parasite);
|
||||
gimp_parasite_free (comment_parasite);
|
||||
|
||||
comment_parasite = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
* jpeg parameters (quaility, smoothing, compression and progressive)
|
||||
* are attached to the image as a parasite. This allows the
|
||||
* parameters to remain consistent between saves. I was not able to
|
||||
* figure out how to determine the quaility, smoothing or compression
|
||||
* figure out how to determine the quality, smoothing or compression
|
||||
* values of an image as it is being loaded, but the code is there to
|
||||
* support it if anyone knows how. Progressive mode is a method of
|
||||
* saving the image such that as a browser (or other app supporting
|
||||
|
@ -696,9 +696,9 @@ my_error_exit (j_common_ptr cinfo)
|
|||
}
|
||||
|
||||
static gint32
|
||||
load_image (gchar *filename,
|
||||
load_image (gchar *filename,
|
||||
GimpRunMode runmode,
|
||||
gboolean preview)
|
||||
gboolean preview)
|
||||
{
|
||||
GimpPixelRgn pixel_rgn;
|
||||
GimpDrawable *drawable;
|
||||
|
@ -775,18 +775,20 @@ load_image (gchar *filename,
|
|||
if (!preview)
|
||||
{
|
||||
/* if we had any comments then make a parasite for them */
|
||||
if (local_image_comments && local_image_comments->len)
|
||||
if (local_image_comments && local_image_comments->len)
|
||||
{
|
||||
gchar *string = local_image_comments->str;
|
||||
gchar *comment = local_image_comments->str;
|
||||
|
||||
g_string_free (local_image_comments, FALSE);
|
||||
|
||||
local_image_comments = NULL;
|
||||
comment_parasite = gimp_parasite_new ("gimp-comment",
|
||||
GIMP_PARASITE_PERSISTENT,
|
||||
strlen (string) + 1, string);
|
||||
}
|
||||
else
|
||||
{
|
||||
comment_parasite = NULL;
|
||||
|
||||
if (g_utf8_validate (comment, -1, NULL))
|
||||
comment_parasite = gimp_parasite_new ("gimp-comment",
|
||||
GIMP_PARASITE_PERSISTENT,
|
||||
strlen (comment) + 1,
|
||||
comment);
|
||||
g_free (comment);
|
||||
}
|
||||
|
||||
/* Do not attach the "jpeg-save-options" parasite to the image
|
||||
|
@ -1054,6 +1056,8 @@ load_image (gchar *filename,
|
|||
{
|
||||
gimp_image_parasite_attach (image_ID, comment_parasite);
|
||||
gimp_parasite_free (comment_parasite);
|
||||
|
||||
comment_parasite = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
* jpeg parameters (quaility, smoothing, compression and progressive)
|
||||
* are attached to the image as a parasite. This allows the
|
||||
* parameters to remain consistent between saves. I was not able to
|
||||
* figure out how to determine the quaility, smoothing or compression
|
||||
* figure out how to determine the quality, smoothing or compression
|
||||
* values of an image as it is being loaded, but the code is there to
|
||||
* support it if anyone knows how. Progressive mode is a method of
|
||||
* saving the image such that as a browser (or other app supporting
|
||||
|
@ -696,9 +696,9 @@ my_error_exit (j_common_ptr cinfo)
|
|||
}
|
||||
|
||||
static gint32
|
||||
load_image (gchar *filename,
|
||||
load_image (gchar *filename,
|
||||
GimpRunMode runmode,
|
||||
gboolean preview)
|
||||
gboolean preview)
|
||||
{
|
||||
GimpPixelRgn pixel_rgn;
|
||||
GimpDrawable *drawable;
|
||||
|
@ -775,18 +775,20 @@ load_image (gchar *filename,
|
|||
if (!preview)
|
||||
{
|
||||
/* if we had any comments then make a parasite for them */
|
||||
if (local_image_comments && local_image_comments->len)
|
||||
if (local_image_comments && local_image_comments->len)
|
||||
{
|
||||
gchar *string = local_image_comments->str;
|
||||
gchar *comment = local_image_comments->str;
|
||||
|
||||
g_string_free (local_image_comments, FALSE);
|
||||
|
||||
local_image_comments = NULL;
|
||||
comment_parasite = gimp_parasite_new ("gimp-comment",
|
||||
GIMP_PARASITE_PERSISTENT,
|
||||
strlen (string) + 1, string);
|
||||
}
|
||||
else
|
||||
{
|
||||
comment_parasite = NULL;
|
||||
|
||||
if (g_utf8_validate (comment, -1, NULL))
|
||||
comment_parasite = gimp_parasite_new ("gimp-comment",
|
||||
GIMP_PARASITE_PERSISTENT,
|
||||
strlen (comment) + 1,
|
||||
comment);
|
||||
g_free (comment);
|
||||
}
|
||||
|
||||
/* Do not attach the "jpeg-save-options" parasite to the image
|
||||
|
@ -1054,6 +1056,8 @@ load_image (gchar *filename,
|
|||
{
|
||||
gimp_image_parasite_attach (image_ID, comment_parasite);
|
||||
gimp_parasite_free (comment_parasite);
|
||||
|
||||
comment_parasite = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
* jpeg parameters (quaility, smoothing, compression and progressive)
|
||||
* are attached to the image as a parasite. This allows the
|
||||
* parameters to remain consistent between saves. I was not able to
|
||||
* figure out how to determine the quaility, smoothing or compression
|
||||
* figure out how to determine the quality, smoothing or compression
|
||||
* values of an image as it is being loaded, but the code is there to
|
||||
* support it if anyone knows how. Progressive mode is a method of
|
||||
* saving the image such that as a browser (or other app supporting
|
||||
|
@ -696,9 +696,9 @@ my_error_exit (j_common_ptr cinfo)
|
|||
}
|
||||
|
||||
static gint32
|
||||
load_image (gchar *filename,
|
||||
load_image (gchar *filename,
|
||||
GimpRunMode runmode,
|
||||
gboolean preview)
|
||||
gboolean preview)
|
||||
{
|
||||
GimpPixelRgn pixel_rgn;
|
||||
GimpDrawable *drawable;
|
||||
|
@ -775,18 +775,20 @@ load_image (gchar *filename,
|
|||
if (!preview)
|
||||
{
|
||||
/* if we had any comments then make a parasite for them */
|
||||
if (local_image_comments && local_image_comments->len)
|
||||
if (local_image_comments && local_image_comments->len)
|
||||
{
|
||||
gchar *string = local_image_comments->str;
|
||||
gchar *comment = local_image_comments->str;
|
||||
|
||||
g_string_free (local_image_comments, FALSE);
|
||||
|
||||
local_image_comments = NULL;
|
||||
comment_parasite = gimp_parasite_new ("gimp-comment",
|
||||
GIMP_PARASITE_PERSISTENT,
|
||||
strlen (string) + 1, string);
|
||||
}
|
||||
else
|
||||
{
|
||||
comment_parasite = NULL;
|
||||
|
||||
if (g_utf8_validate (comment, -1, NULL))
|
||||
comment_parasite = gimp_parasite_new ("gimp-comment",
|
||||
GIMP_PARASITE_PERSISTENT,
|
||||
strlen (comment) + 1,
|
||||
comment);
|
||||
g_free (comment);
|
||||
}
|
||||
|
||||
/* Do not attach the "jpeg-save-options" parasite to the image
|
||||
|
@ -1054,6 +1056,8 @@ load_image (gchar *filename,
|
|||
{
|
||||
gimp_image_parasite_attach (image_ID, comment_parasite);
|
||||
gimp_parasite_free (comment_parasite);
|
||||
|
||||
comment_parasite = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
* jpeg parameters (quaility, smoothing, compression and progressive)
|
||||
* are attached to the image as a parasite. This allows the
|
||||
* parameters to remain consistent between saves. I was not able to
|
||||
* figure out how to determine the quaility, smoothing or compression
|
||||
* figure out how to determine the quality, smoothing or compression
|
||||
* values of an image as it is being loaded, but the code is there to
|
||||
* support it if anyone knows how. Progressive mode is a method of
|
||||
* saving the image such that as a browser (or other app supporting
|
||||
|
@ -696,9 +696,9 @@ my_error_exit (j_common_ptr cinfo)
|
|||
}
|
||||
|
||||
static gint32
|
||||
load_image (gchar *filename,
|
||||
load_image (gchar *filename,
|
||||
GimpRunMode runmode,
|
||||
gboolean preview)
|
||||
gboolean preview)
|
||||
{
|
||||
GimpPixelRgn pixel_rgn;
|
||||
GimpDrawable *drawable;
|
||||
|
@ -775,18 +775,20 @@ load_image (gchar *filename,
|
|||
if (!preview)
|
||||
{
|
||||
/* if we had any comments then make a parasite for them */
|
||||
if (local_image_comments && local_image_comments->len)
|
||||
if (local_image_comments && local_image_comments->len)
|
||||
{
|
||||
gchar *string = local_image_comments->str;
|
||||
gchar *comment = local_image_comments->str;
|
||||
|
||||
g_string_free (local_image_comments, FALSE);
|
||||
|
||||
local_image_comments = NULL;
|
||||
comment_parasite = gimp_parasite_new ("gimp-comment",
|
||||
GIMP_PARASITE_PERSISTENT,
|
||||
strlen (string) + 1, string);
|
||||
}
|
||||
else
|
||||
{
|
||||
comment_parasite = NULL;
|
||||
|
||||
if (g_utf8_validate (comment, -1, NULL))
|
||||
comment_parasite = gimp_parasite_new ("gimp-comment",
|
||||
GIMP_PARASITE_PERSISTENT,
|
||||
strlen (comment) + 1,
|
||||
comment);
|
||||
g_free (comment);
|
||||
}
|
||||
|
||||
/* Do not attach the "jpeg-save-options" parasite to the image
|
||||
|
@ -1054,6 +1056,8 @@ load_image (gchar *filename,
|
|||
{
|
||||
gimp_image_parasite_attach (image_ID, comment_parasite);
|
||||
gimp_parasite_free (comment_parasite);
|
||||
|
||||
comment_parasite = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue