[evince] ps: Make sure page labels are valid utf-8 strings
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince] ps: Make sure page labels are valid utf-8 strings
- Date: Sun, 16 Oct 2011 09:25:20 +0000 (UTC)
commit 150d0cfa2d8f64823f2782d207d717fa3ac340a0
Author: Carlos Garcia Campos <carlosgc gnome org>
Date: Sun Oct 16 11:23:30 2011 +0200
ps: Make sure page labels are valid utf-8 strings
Fixes bug #654263.
backend/ps/ev-spectre.c | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
---
diff --git a/backend/ps/ev-spectre.c b/backend/ps/ev-spectre.c
index 23957cd..e47e5fb 100644
--- a/backend/ps/ev-spectre.c
+++ b/backend/ps/ev-spectre.c
@@ -220,7 +220,21 @@ static char *
ps_document_get_page_label (EvDocument *document,
EvPage *page)
{
- return g_strdup (spectre_page_get_label ((SpectrePage *)page->backend_page));
+ const gchar *label = spectre_page_get_label ((SpectrePage *)page->backend_page);
+ gchar *utf8;
+
+ if (!label)
+ return NULL;
+
+ if (g_utf8_validate (label, -1, NULL))
+ return g_strdup (label);
+
+ /* Try with latin1 and ASCII encondings */
+ utf8 = g_convert (label, -1, "utf-8", "latin1", NULL, NULL, NULL);
+ if (!utf8)
+ utf8 = g_convert (label, -1, "utf-8", "ASCII", NULL, NULL, NULL);
+
+ return utf8;
}
static EvDocumentInfo *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]