aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2010-01-29 00:05:21 +0800
committerMatthew Barnes <mbarnes@redhat.com>2010-01-29 00:08:08 +0800
commit11b4cfaade81bd2fc2751ed0532f8c56f5412921 (patch)
tree7faa7d87540dad93b4ae6a39b9755d65f5876cac /e-util
parentc317280de48117088d99f31fb91e82ecb7d4693a (diff)
downloadgsoc2013-evolution-11b4cfaade81bd2fc2751ed0532f8c56f5412921.tar
gsoc2013-evolution-11b4cfaade81bd2fc2751ed0532f8c56f5412921.tar.gz
gsoc2013-evolution-11b4cfaade81bd2fc2751ed0532f8c56f5412921.tar.bz2
gsoc2013-evolution-11b4cfaade81bd2fc2751ed0532f8c56f5412921.tar.lz
gsoc2013-evolution-11b4cfaade81bd2fc2751ed0532f8c56f5412921.tar.xz
gsoc2013-evolution-11b4cfaade81bd2fc2751ed0532f8c56f5412921.tar.zst
gsoc2013-evolution-11b4cfaade81bd2fc2751ed0532f8c56f5412921.zip
Bug 608160 - Pasting text from FireFox into composer gives just "[?]"
Add UTF-16 to UTF-8 conversion to e_selection_data_get_html().
Diffstat (limited to 'e-util')
-rw-r--r--e-util/e-selection.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/e-util/e-selection.c b/e-util/e-selection.c
index 0569b1366e..21c63023f0 100644
--- a/e-util/e-selection.c
+++ b/e-util/e-selection.c
@@ -284,7 +284,10 @@ e_selection_data_get_html (GtkSelectionData *selection_data)
{
GdkAtom data_type;
const guchar *data = NULL;
+ gchar *utf8_text;
+ gint length;
gint ii;
+ GError *error = NULL;
/* XXX May need to do encoding conversions here.
* Not worrying about it for now. */
@@ -292,12 +295,28 @@ e_selection_data_get_html (GtkSelectionData *selection_data)
g_return_val_if_fail (selection_data != NULL, NULL);
data = gtk_selection_data_get_data (selection_data);
+ length = gtk_selection_data_get_length (selection_data);
data_type = gtk_selection_data_get_data_type (selection_data);
+ /* First validate the data. Assume it's UTF-8 or UTF-16. */
+ if (g_utf8_validate ((const gchar *) data, length - 1, NULL))
+ utf8_text = g_strdup ((const gchar *) data);
+ else
+ utf8_text = g_convert (
+ (const gchar *) data, length,
+ "UTF-8", "UTF-16", NULL, NULL, &error);
+
+ if (error != NULL) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ }
+
/* All HTML atoms are treated the same. */
for (ii = 0; ii < NUM_HTML_ATOMS; ii++)
if (data_type == html_atoms[ii])
- return g_strdup ((gchar *) data);
+ return utf8_text;
+
+ g_free (utf8_text);
return NULL;
}