diff options
author | Carlos Garcia Campos <carlosgc@gnome.org> | 2012-05-13 19:45:55 +0200 |
---|---|---|
committer | Carlos Garcia Campos <carlosgc@gnome.org> | 2012-05-13 19:48:16 +0200 |
commit | 329bb1e2b4f4b58832847bcf805d19ac0fd5ef02 (patch) | |
tree | 9232f65ae5832fd31c3bc81e41ad94793a77fc23 | |
parent | 7714b4e319c48ee915061a172208245ae7c4141b (diff) |
glib: Make sure password is always converted to latin1
Remove the utf8 validation since glib API is supposed to always receive
utf8 strings.
-rw-r--r-- | glib/poppler-document.cc | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/glib/poppler-document.cc b/glib/poppler-document.cc index 21cace81..2b01c294 100644 --- a/glib/poppler-document.cc +++ b/glib/poppler-document.cc @@ -132,6 +132,23 @@ _poppler_document_new_from_pdfdoc (PDFDoc *newDoc, return document; } +static GooString * +poppler_password_to_latin1 (const gchar *password) +{ + gchar *password_latin; + GooString *password_g; + + if (!password) + return NULL; + + password_latin = g_convert(password, -1, "ISO-8859-1", "UTF-8", + NULL, NULL, NULL); + password_g = new GooString (password_latin); + g_free (password_latin); + + return password_g; +} + /** * poppler_document_new_from_file: * @uri: uri of the file to load @@ -162,21 +179,7 @@ poppler_document_new_from_file (const char *uri, if (!filename) return NULL; - password_g = NULL; - if (password != NULL) { - if (g_utf8_validate (password, -1, NULL)) { - gchar *password_latin; - - password_latin = g_convert (password, -1, - "ISO-8859-1", - "UTF-8", - NULL, NULL, NULL); - password_g = new GooString (password_latin); - g_free (password_latin); - } else { - password_g = new GooString (password); - } - } + password_g = poppler_password_to_latin1(password); #ifdef G_OS_WIN32 wchar_t *filenameW; @@ -235,10 +238,7 @@ poppler_document_new_from_data (char *data, obj.initNull(); str = new MemStream(data, 0, length, &obj); - password_g = NULL; - if (password != NULL) - password_g = new GooString (password); - + password_g = poppler_password_to_latin1(password); newDoc = new PDFDoc(str, password_g, password_g); delete password_g; |