diff options
author | Bastien Nocera <hadess@hadess.net> | 2015-07-26 18:23:26 +0200 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2015-07-26 18:25:12 +0200 |
commit | e064a170316e2a737d0625720b706e4c08bae6e6 (patch) | |
tree | 2b831d40a2e21e5a61410ba2c990fb9f1b267423 | |
parent | 5e498fa767475d42a1f0e028eba5d5f6b1192821 (diff) | |
download | grilo-plugins-e064a170316e2a737d0625720b706e4c08bae6e6.tar.gz |
lua-factory: Also try convert HTML from ISO8859-1
The OKGoals source will try and download:
http://www.okgoals.com/page-start_from_108.0_archive_.html
which contains an ISO8859-1 accent, despite being declared as UTF-8. Try
to convert from ISO8859-1 before giving up on the download content.
https://bugzilla.gnome.org/show_bug.cgi?id=752895
-rw-r--r-- | src/lua-factory/grl-lua-library.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/lua-factory/grl-lua-library.c b/src/lua-factory/grl-lua-library.c index ef60907..fb6094b 100644 --- a/src/lua-factory/grl-lua-library.c +++ b/src/lua-factory/grl-lua-library.c @@ -455,9 +455,15 @@ grl_util_fetch_done (GObject *source_object, res, &data, &len, &err)) { data = NULL; } else if (!g_utf8_validate(data, len, NULL)) { - data = NULL; - g_set_error_literal (&err, G_IO_ERROR, G_IO_ERROR_INVALID_DATA, - "Fetched item is not valid UTF-8"); + char *fixed; + fixed = g_convert (data, len, "UTF-8", "ISO8859-1", NULL, NULL, NULL); + if (!fixed) { + g_set_error_literal (&err, G_IO_ERROR, G_IO_ERROR_INVALID_DATA, + "Fetched item is not valid UTF-8 or ISO8859-1"); + data = NULL; + } else { + data = fixed; + } } fo->results[fo->index] = (err == NULL) ? g_strdup (data) : g_strdup (""); |