[poppler] glib/poppler-document.cc

Carlos Garcia Campos carlosgc at kemper.freedesktop.org
Sat Nov 24 09:13:25 PST 2007


 glib/poppler-document.cc |   16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

New commits:
commit 74af7c1209f47ed39addf7fde3ea106a7c77a408
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Sat Nov 24 18:12:00 2007 +0100

    Convert passwords from utf-8 to latin-1 when needed. Fixes bug #4557

diff --git a/glib/poppler-document.cc b/glib/poppler-document.cc
index 98be9c7..16536a9 100644
--- a/glib/poppler-document.cc
+++ b/glib/poppler-document.cc
@@ -136,8 +136,20 @@ poppler_document_new_from_file (const char  *uri,
   g_free (filename);
 
   password_g = NULL;
-  if (password != NULL)
-    password_g = new GooString (password);
+  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);
+    }
+  }
 
   newDoc = new PDFDoc(filename_g, password_g, password_g);
   delete password_g;


More information about the poppler mailing list