summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorraveit65 <[email protected]>2014-04-21 12:18:15 +0200
committerinfirit <[email protected]>2014-09-29 16:18:29 +0200
commitc8caf0cd9de8e31904a60a60fb5e98e55b59555c (patch)
tree7139f9d7f2d01aafade0f364210cc5a47fc1bb8e
parent16ea275cf30821bd54c2e0a5decb5e12ceca5bcf (diff)
downloadatril-c8caf0cd9de8e31904a60a60fb5e98e55b59555c.tar.bz2
atril-c8caf0cd9de8e31904a60a60fb5e98e55b59555c.tar.xz
ps: Make sure page labels are valid utf-8 strings
taken from https://git.gnome.org/browse/evince/commit/?id=150d0cfa2d8f64823f2782d207d717fa3ac340a0
-rw-r--r--backend/ps/ev-spectre.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/backend/ps/ev-spectre.c b/backend/ps/ev-spectre.c
index d28325ba..b0489b78 100644
--- a/backend/ps/ev-spectre.c
+++ b/backend/ps/ev-spectre.c
@@ -224,7 +224,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 *