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

New commits:
commit 54e89a3f0979b9aece428303c7d9c6feb51fd060
Author: Carlos Garcia Campos <[EMAIL PROTECTED]>
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 c4179bb..ca74e45 100644
--- a/glib/poppler-document.cc
+++ b/glib/poppler-document.cc
@@ -137,8 +137,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);
   if (password_g)
_______________________________________________
poppler mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/poppler

Reply via email to