Index: psd.c
===================================================================
RCS file: /cvs/gnome/gimp/plug-ins/common/psd.c,v
retrieving revision 1.47
diff -u -r1.47 psd.c
--- psd.c	15 Nov 2003 13:52:57 -0000	1.47
+++ psd.c	27 Nov 2003 11:58:16 -0000
@@ -1,5 +1,5 @@
 /*
- * PSD Plugin version 3.0.9
+ * PSD Plugin version 3.0.10
  * This GIMP plug-in is designed to load Adobe Photoshop(tm) files (.PSD)
  *
  * Adam D. Moss <adam@gimp.org> <adam@foxbox.org>
@@ -35,6 +35,11 @@
 /*
  * Revision history:
  *
+ *  2003.11.27 / v3.0.10 / Adam D. Moss
+ *       GIMP 1.3/2.0 needs its layer/channel names to be UTF8 or it
+ *       fails wackily, so convert the strings from the PSD file to
+ *       UTF8 instead of using them raw.
+ *
  *  2003-10-05 / v3.0.9 / Morten Eriksen
  *       Fixed memory corruption bug: too little memory was allocated
  *       for the bitmap image buffer if (imgwidth % 8 != 0) for
@@ -454,6 +459,20 @@
     }
 }
 
+
+static char *
+sanitise_string(char *old_name)
+{
+  if (old_name) {
+    char *rtn = gimp_any_to_utf8(old_name, -1,
+				 _("Invalid UTF-8 string in PSD file"));
+    g_free(old_name);
+    return rtn;
+  } else {
+    return NULL;
+  }
+}
+
 static GimpImageType
 psd_type_to_gimp_type (psd_imagetype psdtype)
 {
@@ -619,6 +638,8 @@
 		    {
 		      sname = getstring(slen, fd, "alpha channel name");
 
+		      sname = sanitise_string(sname);
+
 		      psd_image.aux_channel[psd_image.num_aux_channels].name =
 			sname;
 		    }
@@ -1055,6 +1076,7 @@
     }
 
   layer->name = getpascalstring(fd, "layer name");
+  layer->name = sanitise_string(layer->name);
   (*offset)++;
 
   if (layer->name)
