refuse to write comments that contain non-ASCII characters.
2003-07-03 Sven Neumann <sven@gimp.org> * plug-ins/common/gif.c (save_image): refuse to write comments that contain non-ASCII characters.
This commit is contained in:

committed by
Sven Neumann

parent
c7f573cc55
commit
aa28c532ab
@ -1,3 +1,8 @@
|
|||||||
|
2003-07-03 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
|
* plug-ins/common/gif.c (save_image): refuse to write comments that
|
||||||
|
contain non-ASCII characters.
|
||||||
|
|
||||||
2003-07-03 Sven Neumann <sven@gimp.org>
|
2003-07-03 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
* plug-ins/common/png.c: added a toggle that allows to disable
|
* plug-ins/common/png.c: added a toggle that allows to disable
|
||||||
|
@ -513,7 +513,8 @@ run (const gchar *name,
|
|||||||
orig_image_ID))
|
orig_image_ID))
|
||||||
{
|
{
|
||||||
/* Store psvals data */
|
/* Store psvals data */
|
||||||
gimp_set_data ("file_gif_save", &gsvals, sizeof (GIFSaveVals));
|
gimp_set_data ("file_gif_save",
|
||||||
|
&gsvals, sizeof (GIFSaveVals));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -592,15 +593,15 @@ typedef long int count_int;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int find_unused_ia_colour (guchar *pixels,
|
static gint find_unused_ia_colour (guchar *pixels,
|
||||||
int numpixels,
|
gint numpixels,
|
||||||
int num_indices,
|
gint num_indices,
|
||||||
int* colors);
|
gint *colors);
|
||||||
|
|
||||||
void special_flatten_indexed_alpha (guchar *pixels,
|
static void special_flatten_indexed_alpha (guchar *pixels,
|
||||||
int *transparent,
|
gint *transparent,
|
||||||
int *colors,
|
gint *colors,
|
||||||
int numpixels);
|
gint numpixels);
|
||||||
static int colorstobpp (int);
|
static int colorstobpp (int);
|
||||||
static int bpptocolors (int);
|
static int bpptocolors (int);
|
||||||
static int GetPixel (int, int);
|
static int GetPixel (int, int);
|
||||||
@ -615,7 +616,7 @@ static void GIFEncodeImageData (FILE *, int, int, int, int,
|
|||||||
ifunptr, gint, gint);
|
ifunptr, gint, gint);
|
||||||
static void GIFEncodeClose (FILE *);
|
static void GIFEncodeClose (FILE *);
|
||||||
static void GIFEncodeLoopExt (FILE *, guint);
|
static void GIFEncodeLoopExt (FILE *, guint);
|
||||||
static void GIFEncodeCommentExt (FILE *, char *);
|
static void GIFEncodeCommentExt (FILE *, const gchar *comment);
|
||||||
|
|
||||||
int rowstride;
|
int rowstride;
|
||||||
guchar *pixels;
|
guchar *pixels;
|
||||||
@ -634,10 +635,11 @@ static void flush_char (void);
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int find_unused_ia_colour (guchar *pixels,
|
static gint
|
||||||
int numpixels,
|
find_unused_ia_colour (guchar *pixels,
|
||||||
int num_indices,
|
gint numpixels,
|
||||||
int* colors)
|
gint num_indices,
|
||||||
|
gint *colors)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
gboolean ix_used[256];
|
gboolean ix_used[256];
|
||||||
@ -685,7 +687,7 @@ static int find_unused_ia_colour (guchar *pixels,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
static void
|
||||||
special_flatten_indexed_alpha (guchar *pixels,
|
special_flatten_indexed_alpha (guchar *pixels,
|
||||||
int *transparent,
|
int *transparent,
|
||||||
int *colors,
|
int *colors,
|
||||||
@ -723,7 +725,7 @@ special_flatten_indexed_alpha (guchar *pixels,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
static int
|
||||||
parse_ms_tag (char *str)
|
parse_ms_tag (char *str)
|
||||||
{
|
{
|
||||||
gint sum = 0;
|
gint sum = 0;
|
||||||
@ -761,7 +763,7 @@ find_another_bra:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
static int
|
||||||
parse_disposal_tag (char *str)
|
parse_disposal_tag (char *str)
|
||||||
{
|
{
|
||||||
gint offset = 0;
|
gint offset = 0;
|
||||||
@ -891,6 +893,26 @@ save_image (const gchar *filename,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* The GIF spec says 7bit ASCII for the comment block. */
|
||||||
|
if (gsvals.save_comment && globalcomment)
|
||||||
|
{
|
||||||
|
const gchar *c = globalcomment;
|
||||||
|
gint len;
|
||||||
|
|
||||||
|
for (len = strlen (c); len; c++, len--)
|
||||||
|
{
|
||||||
|
if (*c < 0)
|
||||||
|
{
|
||||||
|
g_message (_("The GIF format only supports comments in\n"
|
||||||
|
"7bit ASCII encoding. No comment is saved."));
|
||||||
|
|
||||||
|
g_free (globalcomment);
|
||||||
|
globalcomment = NULL;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* get a list of layers for this image_ID */
|
/* get a list of layers for this image_ID */
|
||||||
layers = gimp_image_get_layers (image_ID, &nlayers);
|
layers = gimp_image_get_layers (image_ID, &nlayers);
|
||||||
@ -1962,23 +1984,25 @@ GIFEncodeLoopExt (FILE *fp,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void GIFEncodeCommentExt (FILE *fp, char *comment)
|
static void
|
||||||
|
GIFEncodeCommentExt (FILE *fp,
|
||||||
|
const gchar *comment)
|
||||||
{
|
{
|
||||||
if (!comment || !*comment)
|
if (!comment || !*comment)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (strlen(comment)>240)
|
if (strlen (comment) > 240)
|
||||||
{
|
{
|
||||||
g_printerr ("GIF: warning:"
|
g_printerr ("GIF: warning:"
|
||||||
"comment too large - comment block not written.\n");
|
"comment too large - comment block not written.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fputc(0x21,fp);
|
fputc (0x21, fp);
|
||||||
fputc(0xfe,fp);
|
fputc (0xfe, fp);
|
||||||
fputc(strlen(comment),fp);
|
fputc (strlen (comment), fp);
|
||||||
fputs((const char *)comment,fp);
|
fputs (comment, fp);
|
||||||
fputc(0x00,fp);
|
fputc (0x00, fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user