aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-12-24 15:41:01 +0000
committerChristian Grothoff <christian@grothoff.org>2011-12-24 15:41:01 +0000
commitbc8959497fd96585bde441c2b2bc484c195db4e4 (patch)
tree67ab53a8400656b2ea9d7d86ac92ec21f61d21a3
parent8f49767695fbc4dd9faa81aeb09cc8b5f91a64fb (diff)
downloadgnunet-gtk-bc8959497fd96585bde441c2b2bc484c195db4e4.tar.gz
gnunet-gtk-bc8959497fd96585bde441c2b2bc484c195db4e4.zip
-LRN: better metadata insertion, check for string encoding errors
-rw-r--r--src/fs/gnunet-fs-gtk-common.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/fs/gnunet-fs-gtk-common.c b/src/fs/gnunet-fs-gtk-common.c
index e9c052e6..b2bf9b26 100644
--- a/src/fs/gnunet-fs-gtk-common.c
+++ b/src/fs/gnunet-fs-gtk-common.c
@@ -59,11 +59,25 @@ GNUNET_FS_GTK_add_meta_data_to_list_store (void *cls, const char *plugin_name,
59 if (g_utf8_validate (data, data_len, NULL)) 59 if (g_utf8_validate (data, data_len, NULL))
60 data_to_insert = data; 60 data_to_insert = data;
61 else 61 else
62 {
63 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
64 "Failed to validate supposedly utf-8 string `%s' of length %u, assuming it to be a C string\n",
65 data, data_len);
62 format = EXTRACTOR_METAFORMAT_C_STRING; 66 format = EXTRACTOR_METAFORMAT_C_STRING;
67 }
63 } 68 }
64 if (format == EXTRACTOR_METAFORMAT_C_STRING) 69 if (format == EXTRACTOR_METAFORMAT_C_STRING)
65 { 70 {
66 free_data = g_locale_to_utf8 (data, data_len, &rd, &wr, NULL); 71 GError *gerr = NULL;
72 rd = wr = 0;
73 free_data = g_locale_to_utf8 (data, data_len, &rd, &wr, &gerr);
74 if (gerr != NULL)
75 {
76 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
77 "Error when converting a C string `%s' of length %u to utf-8 (converted %u to %u bytes): %s\n",
78 data, data_len, rd, wr, gerr->message);
79 g_error_free (gerr);
80 }
67 data_to_insert = free_data; 81 data_to_insert = free_data;
68 } 82 }
69 83