From 84ff512cfab1f2ca0a511e8a28250bf71270facf Mon Sep 17 00:00:00 2001 From: Alx Sa Date: Sat, 22 Nov 2025 17:49:33 +0000 Subject: [PATCH] path: Use generic ID for path export Resolves #13570 The SVG specification prohibits certain characters from being used as part of a path id attribute, such as whitespace and hyphens. Rather than try to filter the path name selected by the user, this patch switches to an auto-incrementing "path%d" format to ensure any exported path can be read by strict parsers. This also matches how we implemented ids in the SVG export plug-in. --- app/path/gimppath-export.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/app/path/gimppath-export.c b/app/path/gimppath-export.c index 55f508fa02..09e6941d95 100644 --- a/app/path/gimppath-export.c +++ b/app/path/gimppath-export.c @@ -41,7 +41,8 @@ static GString * gimp_path_export (GimpImage *image, static void gimp_path_export_image_size (GimpImage *image, GString *str); static void gimp_path_export_path (GimpPath *paths, - GString *str); + GString *str, + gint path_id); static gchar * gimp_path_export_path_data (GimpPath *paths); @@ -139,7 +140,8 @@ static GString * gimp_path_export (GimpImage *image, GList *path) { - GString *str = g_string_new (NULL); + GString *str = g_string_new (NULL); + gint path_id = 1; GList *list; g_string_append_printf (str, @@ -161,7 +163,7 @@ gimp_path_export (GimpImage *image, path = gimp_image_get_path_iter (image); for (list = path; list; list = list->next) - gimp_path_export_path (GIMP_PATH (list->data), str); + gimp_path_export_path (GIMP_PATH (list->data), str, path_id++); g_string_append (str, "\n"); @@ -210,21 +212,24 @@ gimp_path_export_image_size (GimpImage *image, static void gimp_path_export_path (GimpPath *path, - GString *str) + GString *str, + gint path_id) { - const gchar *name = gimp_object_get_name (path); - gchar *data = gimp_path_export_path_data (path); - gchar *esc_name; + gchar *name; + gchar *data = gimp_path_export_path_data (path); - esc_name = g_markup_escape_text (name, strlen (name)); + /* SVG specification states the id attribute must not contain whitespace. + * Rather than filter user names, we'll just define a generic, + * auto-incrementing id. */ + name = g_strdup_printf ("path%d", path_id); g_string_append_printf (str, " \n", - esc_name, data); + name, data); - g_free (esc_name); + g_free (name); g_free (data); }