[poppler] Branch 'poppler-0.20' - glib/poppler-document.cc
Carlos Garcia Campos
carlosgc at kemper.freedesktop.org
Sun May 13 10:48:49 PDT 2012
glib/poppler-document.cc | 38 +++++++++++++++++++-------------------
1 file changed, 19 insertions(+), 19 deletions(-)
New commits:
commit 329bb1e2b4f4b58832847bcf805d19ac0fd5ef02
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date: Sun May 13 19:45:55 2012 +0200
glib: Make sure password is always converted to latin1
Remove the utf8 validation since glib API is supposed to always receive
utf8 strings.
diff --git a/glib/poppler-document.cc b/glib/poppler-document.cc
index 21cace8..2b01c29 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;
More information about the poppler
mailing list