Adapted Sven's code into pdbgen so that gimp_image_set_filename()

2004-11-13  Manish Singh  <yosh@gimp.org>

        * tools/pdbgen/pdb/image.pdb: Adapted Sven's code into pdbgen so
        that gimp_image_set_filename() validates that it is called with
        a filename in the filesystem encoding which can safely be converted
        to UTF-8 and back. Fixes #153751.

        * app/pdb/image_cmds.c
        * libgimp/gimpimage_pdb.c: Regenerated.
This commit is contained in:
Manish Singh 2004-11-14 00:35:24 +00:00 committed by Manish Singh
parent 5ce8292af8
commit c563a249b9
4 changed files with 56 additions and 4 deletions

View file

@ -1,3 +1,13 @@
2004-11-13 Manish Singh <yosh@gimp.org>
* tools/pdbgen/pdb/image.pdb: Adapted Sven's code into pdbgen so
that gimp_image_set_filename() validates that it is called with
a filename in the filesystem encoding which can safely be converted
to UTF-8 and back. Fixes #153751.
* app/pdb/image_cmds.c
* libgimp/gimpimage_pdb.c: Regenerated.
2004-11-13 Sven Neumann <sven@gimp.org>
* app/dialogs/Makefile.am
@ -40,7 +50,7 @@
in UTF-8 encoding.
* app/pdb/image_cmds.c
* libgimp/gimpimage_pdb.c
* libgimp/gimpimage_pdb.c: Regenerated.
* app/vectors/gimpbezierstroke.h: formatting.

View file

@ -3806,7 +3806,25 @@ image_set_filename_invoker (Gimp *gimp,
success = FALSE;
if (success)
gimp_image_set_filename (gimage, filename);
{
/* verify that the filename can be converted to UTF-8 and back */
gchar *utf8 = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL);
if (utf8)
{
gchar *tmp = g_filename_from_utf8 (utf8, -1, NULL, NULL, NULL);
if (tmp)
g_free (tmp);
else
success = FALSE;
}
else
success = FALSE;
if (success)
gimp_image_set_filename (gimage, filename);
}
return procedural_db_return_args (&image_set_filename_proc, success);
}
@ -3829,7 +3847,7 @@ static ProcRecord image_set_filename_proc =
{
"gimp_image_set_filename",
"Sets the specified image's filename.",
"This procedure sets the specified image's filename.",
"This procedure sets the specified image's filename. The filename should be in the filesystem encoding.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",

View file

@ -1868,7 +1868,8 @@ gimp_image_get_filename (gint32 image_ID)
*
* Sets the specified image's filename.
*
* This procedure sets the specified image's filename.
* This procedure sets the specified image's filename. The filename
* should be in the filesystem encoding.
*
* Returns: TRUE on success.
*/

View file

@ -1289,8 +1289,31 @@ HELP
$outargs[0]->{alias} =~ s/g_strdup \((.*)\)/$1/;
CODE1
$help .= " The filename should be in the filesystem encoding.";
$inargs[1]->{no_validate} = 1;
$invoke{code} = <<CODE3;
{
/* verify that the filename can be converted to UTF-8 and back */
gchar *utf8 = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL);
if (utf8)
{
gchar *tmp = g_filename_from_utf8 (utf8, -1, NULL, NULL, NULL);
if (tmp)
g_free (tmp);
else
success = FALSE;
}
else
success = FALSE;
if (success)
$invoke{code}
}
CODE3
CODE2
&image_accessors('name', 'string', 'name', 1,