[gimp] app, libgimp: also UTF-8-validate all elements of PDB string arrays
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app, libgimp: also UTF-8-validate all elements of PDB string arrays
- Date: Mon, 19 Aug 2019 23:47:34 +0000 (UTC)
commit 0f273a5959796920c959c9620eaa952b10a1e1bb
Author: Michael Natterer <mitch gimp org>
Date: Tue Aug 20 01:46:56 2019 +0200
app, libgimp: also UTF-8-validate all elements of PDB string arrays
app/pdb/gimpprocedure.c | 29 ++++++++++++++++++++++++++---
libgimp/gimpprocedure.c | 29 ++++++++++++++++++++++++++---
2 files changed, 52 insertions(+), 6 deletions(-)
---
diff --git a/app/pdb/gimpprocedure.c b/app/pdb/gimpprocedure.c
index bdc623946f..38baf68b40 100644
--- a/app/pdb/gimpprocedure.c
+++ b/app/pdb/gimpprocedure.c
@@ -883,11 +883,34 @@ gimp_procedure_validate_args (GimpProcedure *procedure,
}
/* UTT-8 validate all strings */
- if (G_PARAM_SPEC_TYPE (pspec) == G_TYPE_PARAM_STRING)
+ if (G_PARAM_SPEC_TYPE (pspec) == G_TYPE_PARAM_STRING ||
+ G_PARAM_SPEC_TYPE (pspec) == GIMP_TYPE_PARAM_STRING_ARRAY)
{
- const gchar *string = g_value_get_string (arg);
+ gboolean valid = TRUE;
- if (string && ! g_utf8_validate (string, -1, NULL))
+ if (G_PARAM_SPEC_TYPE (pspec) == G_TYPE_PARAM_STRING)
+ {
+ const gchar *string = g_value_get_string (arg);
+
+ if (string)
+ valid = g_utf8_validate (string, -1, NULL);
+ }
+ else
+ {
+ const GimpArray *array = g_value_get_boxed (arg);
+
+ if (array)
+ {
+ const gchar **strings = (const gchar **) array->data;
+ gint i;
+
+ for (i = 0; i < array->length && valid; i++)
+ if (strings[i])
+ valid = g_utf8_validate (strings[i], -1, NULL);
+ }
+ }
+
+ if (! valid)
{
if (return_vals)
{
diff --git a/libgimp/gimpprocedure.c b/libgimp/gimpprocedure.c
index 78e0ccd666..ea719d825c 100644
--- a/libgimp/gimpprocedure.c
+++ b/libgimp/gimpprocedure.c
@@ -1508,11 +1508,34 @@ gimp_procedure_validate_args (GimpProcedure *procedure,
}
/* UTT-8 validate all strings */
- if (G_PARAM_SPEC_TYPE (pspec) == G_TYPE_PARAM_STRING)
+ if (G_PARAM_SPEC_TYPE (pspec) == G_TYPE_PARAM_STRING ||
+ G_PARAM_SPEC_TYPE (pspec) == GIMP_TYPE_PARAM_STRING_ARRAY)
{
- const gchar *string = g_value_get_string (arg);
+ gboolean valid = TRUE;
- if (string && ! g_utf8_validate (string, -1, NULL))
+ if (G_PARAM_SPEC_TYPE (pspec) == G_TYPE_PARAM_STRING)
+ {
+ const gchar *string = g_value_get_string (arg);
+
+ if (string)
+ valid = g_utf8_validate (string, -1, NULL);
+ }
+ else
+ {
+ const GimpArray *array = g_value_get_boxed (arg);
+
+ if (array)
+ {
+ const gchar **strings = (const gchar **) array->data;
+ gint i;
+
+ for (i = 0; i < array->length && valid; i++)
+ if (strings[i])
+ valid = g_utf8_validate (strings[i], -1, NULL);
+ }
+ }
+
+ if (! valid)
{
if (return_vals)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]