[gnome-nettool] whois: avoid freeze when enconding isn'n the expected Closes: gnome#503587
- From: Germán Poó Caamaño <gpoo src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-nettool] whois: avoid freeze when enconding isn'n the expected Closes: gnome#503587
- Date: Mon, 4 May 2009 00:21:27 -0400 (EDT)
commit 33e9ddaa5ee75c2b7b3713c51bf66c9bc4e2dd70
Author: Antonio Litterio <antonio litterio gmail com>
Date: Mon May 4 00:18:47 2009 -0400
whois: avoid freeze when enconding isn'n the expected Closes: gnome#503587
Signed-off-by: Germán Póo-Caamaño <gpoo gnome org>
---
src/nettool.c | 24 +++++++++++++++++++++++-
1 files changed, 23 insertions(+), 1 deletions(-)
diff --git a/src/nettool.c b/src/nettool.c
index 45c0f36..88e880a 100644
--- a/src/nettool.c
+++ b/src/nettool.c
@@ -329,6 +329,8 @@ netinfo_io_text_buffer_dialog (GIOChannel * channel,
gchar *text = NULL;
gsize len;
Netinfo *netinfo = (Netinfo *) data;
+ GError *err = NULL;
+ const gchar *encoding;
g_return_val_if_fail (channel != NULL, FALSE);
g_return_val_if_fail (netinfo != NULL, FALSE);
@@ -357,7 +359,7 @@ netinfo_io_text_buffer_dialog (GIOChannel * channel,
if (condition & G_IO_IN) {
GIOStatus status;
- status = g_io_channel_read_line (channel, &text, &len, NULL, NULL);
+ status = g_io_channel_read_line (channel, &text, &len, NULL, &err);
if (status == G_IO_STATUS_NORMAL) {
if (netinfo->command_output) {
@@ -384,6 +386,26 @@ netinfo_io_text_buffer_dialog (GIOChannel * channel,
g_string_append_c (netinfo->command_output, buf[0]);
}
} else if (status == G_IO_STATUS_EOF) {
+
+ } else if (status == G_IO_STATUS_ERROR) {
+ encoding = g_io_channel_get_encoding (channel);
+
+ if (err->code == G_CONVERT_ERROR_ILLEGAL_SEQUENCE) {
+ g_warning ("Warning: change of encoding: %s. The encoding "
+ "was changed from %s to ISO-8859-1 only "
+ "for this string\n",
+ err->message,
+ encoding);
+
+ g_io_channel_set_encoding (channel, "ISO-8859-1", NULL);
+ g_io_channel_read_line (channel, &text, &len, NULL, NULL);
+
+ } else {
+ g_warning ("Error: %s\n", err->message);
+ g_free (text);
+ g_free (err);
+ }
+
}
g_free (text);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]