[gimp] app, libgimp: UTF-8 validate all string arguments and return values
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app, libgimp: UTF-8 validate all string arguments and return values
- Date: Mon, 19 Aug 2019 11:12:04 +0000 (UTC)
commit fab806089ab3c78b920738d8f1b6844aaec61178
Author: Michael Natterer <mitch gimp org>
Date: Mon Aug 19 13:11:02 2019 +0200
app, libgimp: UTF-8 validate all string arguments and return values
The only way for a plug-in to prevent this is now using
GIMP_PARAM_NO_VALIDATE.
app/pdb/gimpprocedure.c | 34 ++++++++++++++++++++++++++++++++++
libgimp/gimpprocedure.c | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 68 insertions(+)
---
diff --git a/app/pdb/gimpprocedure.c b/app/pdb/gimpprocedure.c
index ebb00d72e7..bdc623946f 100644
--- a/app/pdb/gimpprocedure.c
+++ b/app/pdb/gimpprocedure.c
@@ -882,6 +882,40 @@ gimp_procedure_validate_args (GimpProcedure *procedure,
return FALSE;
}
+ /* UTT-8 validate all strings */
+ if (G_PARAM_SPEC_TYPE (pspec) == G_TYPE_PARAM_STRING)
+ {
+ const gchar *string = g_value_get_string (arg);
+
+ if (string && ! g_utf8_validate (string, -1, NULL))
+ {
+ if (return_vals)
+ {
+ g_set_error (error,
+ GIMP_PDB_ERROR,
+ GIMP_PDB_ERROR_INVALID_RETURN_VALUE,
+ _("Procedure '%s' returned an "
+ "invalid UTF-8 string for argument '%s'."),
+ gimp_object_get_name (procedure),
+ g_param_spec_get_name (pspec));
+ }
+ else
+ {
+ g_set_error (error,
+ GIMP_PDB_ERROR,
+ GIMP_PDB_ERROR_INVALID_ARGUMENT,
+ _("Procedure '%s' has been called with an "
+ "invalid UTF-8 string for argument '%s'."),
+ gimp_object_get_name (procedure),
+ g_param_spec_get_name (pspec));
+ }
+
+ g_value_unset (&string_value);
+
+ return FALSE;
+ }
+ }
+
g_value_unset (&string_value);
}
}
diff --git a/libgimp/gimpprocedure.c b/libgimp/gimpprocedure.c
index 4443881463..78e0ccd666 100644
--- a/libgimp/gimpprocedure.c
+++ b/libgimp/gimpprocedure.c
@@ -1507,6 +1507,40 @@ gimp_procedure_validate_args (GimpProcedure *procedure,
return FALSE;
}
+ /* UTT-8 validate all strings */
+ if (G_PARAM_SPEC_TYPE (pspec) == G_TYPE_PARAM_STRING)
+ {
+ const gchar *string = g_value_get_string (arg);
+
+ if (string && ! g_utf8_validate (string, -1, NULL))
+ {
+ if (return_vals)
+ {
+ g_set_error (error,
+ GIMP_PDB_ERROR,
+ GIMP_PDB_ERROR_INVALID_RETURN_VALUE,
+ _("Procedure '%s' returned an "
+ "invalid UTF-8 string for argument '%s'."),
+ gimp_procedure_get_name (procedure),
+ g_param_spec_get_name (pspec));
+ }
+ else
+ {
+ g_set_error (error,
+ GIMP_PDB_ERROR,
+ GIMP_PDB_ERROR_INVALID_ARGUMENT,
+ _("Procedure '%s' has been called with an "
+ "invalid UTF-8 string for argument '%s'."),
+ gimp_procedure_get_name (procedure),
+ g_param_spec_get_name (pspec));
+ }
+
+ g_value_unset (&string_value);
+
+ return FALSE;
+ }
+ }
+
g_value_unset (&string_value);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]