aboutsummaryrefslogtreecommitdiff
path: root/src/stardict.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2016-09-28 03:03:42 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2016-09-28 03:03:42 +0200
commitff0ec609312d150cc8c790277c678cad76b38f30 (patch)
tree9ed18db536e694a72c894fa4910762792e69ecd6 /src/stardict.c
parent474bcb518ad93aa32a0c63d3d71ffe50e908ae65 (diff)
downloadtdv-ff0ec609312d150cc8c790277c678cad76b38f30.tar.gz
tdv-ff0ec609312d150cc8c790277c678cad76b38f30.tar.xz
tdv-ff0ec609312d150cc8c790277c678cad76b38f30.zip
Validate encoding in .ifo files
Diffstat (limited to 'src/stardict.c')
-rw-r--r--src/stardict.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/stardict.c b/src/stardict.c
index b7e7be4..1010ee1 100644
--- a/src/stardict.c
+++ b/src/stardict.c
@@ -253,6 +253,13 @@ load_ifo (StardictInfo *sti, const gchar *path, GError **error)
continue;
}
+ if (!g_utf8_validate (ir.value, -1, NULL))
+ {
+ g_set_error (error, STARDICT_ERROR, STARDICT_ERROR_INVALID_DATA,
+ "%s: %s", path, _("invalid encoding, must be valid UTF-8"));
+ goto error;
+ }
+
if (_stardict_ifo_keys[i].type == IFO_STRING)
{
G_STRUCT_MEMBER (gchar *, sti, _stardict_ifo_keys[i].offset)