diff options
author | Bastien Nocera <hadess@hadess.net> | 2015-07-21 19:48:34 +0200 |
---|---|---|
committer | Victor Toso <me@victortoso.com> | 2015-07-23 18:11:50 +0200 |
commit | d5e489d2acc98dd1964dde8236b5b4a75ba99d7f (patch) | |
tree | 4f557404bcc2d067b052f5f11f4e1d45df81bb45 | |
parent | 46d7ebff52b8c936f32140b457d5f9c0e6e83b50 (diff) | |
download | grilo-plugins-d5e489d2acc98dd1964dde8236b5b4a75ba99d7f.tar.gz |
lua-factory: Fix performer key containing only one name
Fix the handling of arrays of strings. We shouldn't always overwrite the
names previously there, especially as the key is emptied before handling
tables of values.
https://bugzilla.gnome.org/show_bug.cgi?id=752681
-rw-r--r-- | src/lua-factory/grl-lua-library.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/lua-factory/grl-lua-library.c b/src/lua-factory/grl-lua-library.c index ab74bae..ed0e98a 100644 --- a/src/lua-factory/grl-lua-library.c +++ b/src/lua-factory/grl-lua-library.c @@ -193,6 +193,31 @@ grl_data_set_lua_string (GrlData *data, } } +static void +grl_data_add_lua_string (GrlData *data, + GrlKeyID key_id, + const char *key_name, + const char *str) +{ + char *fixed = NULL; + + /* Check for UTF-8 or ISO8859-1 string */ + if (g_utf8_validate (str, -1, NULL) == FALSE) { + fixed = g_convert (str, -1, "UTF-8", "ISO8859-1", NULL, NULL, NULL); + if (fixed == NULL) { + GRL_WARNING ("Ignored non-UTF-8 and non-ISO8859-1 string for field '%s'", key_name); + return; + } + } + + if (fixed) { + grl_data_add_string (data, key_id, fixed); + g_free (fixed); + } else { + grl_data_add_string (data, key_id, str); + } +} + static gboolean verify_plaintext_fetch (GrlSource *source, char **urls, @@ -256,7 +281,7 @@ grl_util_add_table_to_media (lua_State *L, case G_TYPE_STRING: if (lua_isstring (L, -1)) - grl_data_set_lua_string (GRL_DATA (media), key_id, key_name, lua_tostring (L, -1)); + grl_data_add_lua_string (GRL_DATA (media), key_id, key_name, lua_tostring (L, -1)); break; default: |