forwarded 508969 jo...@emma-soft.com
thanks
On mer, 2008-12-17 at 02:37 +0100, Olof Johansson wrote:

> I noticed that when I mistakenly entered a filename to a file which
> didn't exist, epdfview started to ask for a password to decrypt the
> file! Cancelling caused epdfview to disallow opening new files and
> made it necessary to restart the program. I confirmed this behaviour
> on a freshly installed machine.
> 
> The problem was if poppler couldn't open the document it set
> POPPLER_ERROR but epdfview interpreted this as an encrytption error.
> With my proposed patch the problems seems to have bin fixed, at least 
> for me; asking for password when trying to open encrypted files and 
> alerting the user that it wasn't able to open the file, if the file 
> is non-existent.

Hi,

I agreed, I've been bitten by this bug too. I'll forward the bug/patch
upstream (Hi Jordi!), and see about including it in the Debian package.

Cheers,
-- 
Yves-Alexis
--- epdfview-0.1.6.orig/src/PDFDocument.cxx	2008-12-16 14:21:53.000000000 +0100
+++ epdfview-0.1.6/src/PDFDocument.cxx	2008-12-17 02:05:07.000000000 +0100
@@ -19,6 +19,7 @@
 #include <gdk/gdk.h>
 #include <time.h>
 #include <poppler.h>
+#include <poppler/ErrorCodes.h>
 #include <unistd.h>
 #include "epdfview.h"
 
@@ -210,7 +211,7 @@
         return FALSE;
     }
     // Try to open the PDF document.
-    GError *loadError = NULL;
+
     // In case the user specified to read the PDF file from the stdin
     // (i.e., -), then we save the contents of the stdin to a temporary
     // file and use the URI to this temporary file to load.
@@ -241,38 +242,13 @@
         }
     }
     PopplerDocument *newDocument =
-        poppler_document_new_from_file (filename_uri, password, &loadError);
+        poppler_document_new_from_file (filename_uri, password, error);
     g_free (filename_uri);
-    // Check if the document couldn't be opened successfully and why.
-    if ( NULL == newDocument )
-    {
-        // Poppler's glib wrapper passes the Poppler error code unless the
-        // error is that the file is encrypted. We want to set our own
-        // error code in this case.
-        DocumentError errorCode = DocumentErrorNone;
-        if ( POPPLER_ERROR == loadError->domain )
-        {
-            errorCode = DocumentErrorEncrypted;
-        }
-        else
-        {
-            // OK, the glib's wrapper don't pass the error code directly
-            // from Poppler. Instead returns G_FILE_ERROR_FAILED and a 
-            // non translated string.
-            // Maybe I'm wrong (very probable) but that's a wrong way.
-            // So I'm reading the error code from the error string...
-            sscanf (loadError->message, "Failed to load document (error %d)",
-                    (gint *)&errorCode);
-        }
-        g_error_free (loadError);
-        // Get our error message.
-        gchar *errorMessage = IDocument::getErrorMessage (errorCode);
-        g_set_error (error,
-                     EPDFVIEW_DOCUMENT_ERROR, errorCode,
-                     _("Failed to load document '%s'.\n%s\n"),
-                     filename, errorMessage);
-        g_free (errorMessage);
 
+    // Check if the document couldn't be opened successfully and why.
+    if ( !newDocument && (*error)->code ) {
+        if((*error)->code==POPPLER_ERROR_ENCRYPTED)
+            (*error)->code = DocumentErrorEncrypted;
         return FALSE;
     }
 

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to