[poppler] [patch] Add additional user access permissions

Brad Hards bradh at frogmouth.net
Mon Jul 4 14:46:36 PDT 2005


Section 3.5.2 of the PDF spec is about the standard encryption handler - 
within that, Table 3.20 identifies a number of properties that we aren't 
handling, or aren't handling exacty. Just as an indication, here is a simple 
example about printing - see below.

Any objections to adding the rest of the properties to the API? 

Any suggestions for what to do if we get an unknown security handler version?

Brad

Index: PDFDoc.h
===================================================================
RCS file: /cvs/poppler/poppler/poppler/PDFDoc.h,v
retrieving revision 1.1.1.1
diff -u -4 -p -r1.1.1.1 PDFDoc.h
--- PDFDoc.h    3 Mar 2005 19:46:01 -0000       1.1.1.1
+++ PDFDoc.h    4 Jul 2005 21:42:06 -0000
@@ -131,8 +131,10 @@ public:

   // Check various permissions.
   GBool okToPrint(GBool ignoreOwnerPW = gFalse)
     { return xref->okToPrint(ignoreOwnerPW); }
+  GBool okToPrintHighRes(GBool ignoreOwnerPW = gFalse)
+    { return xref->okToPrintHighRes(ignoreOwnerPW); }
   GBool okToChange(GBool ignoreOwnerPW = gFalse)
     { return xref->okToChange(ignoreOwnerPW); }
   GBool okToCopy(GBool ignoreOwnerPW = gFalse)
     { return xref->okToCopy(ignoreOwnerPW); }
Index: XRef.h
===================================================================
RCS file: /cvs/poppler/poppler/poppler/XRef.h,v
retrieving revision 1.1.1.1
diff -u -4 -p -r1.1.1.1 XRef.h
--- XRef.h      3 Mar 2005 19:46:01 -0000       1.1.1.1
+++ XRef.h      4 Jul 2005 21:42:06 -0000
@@ -60,8 +60,9 @@ public:
 #endif

   // Check various permissions.
   GBool okToPrint(GBool ignoreOwnerPW = gFalse);
+  GBool okToPrintHighRes(GBool ignoreOwnerPW = gFalse);
   GBool okToChange(GBool ignoreOwnerPW = gFalse);
   GBool okToCopy(GBool ignoreOwnerPW = gFalse);
   GBool okToAddNotes(GBool ignoreOwnerPW = gFalse);

Index: XRef.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/XRef.cc,v
retrieving revision 1.2
diff -u -4 -p -r1.2 XRef.cc
--- XRef.cc     16 Mar 2005 15:51:36 -0000      1.2
+++ XRef.cc     4 Jul 2005 21:42:06 -0000
@@ -36,14 +36,16 @@

 #ifndef NO_DECRYPTION
 //------------------------------------------------------------------------
 // Permission bits
+// Note that the PDF spec uses 1 base (eg bit 3 is 1<<2)
 //------------------------------------------------------------------------

 #define permPrint    (1<<2)
 #define permChange   (1<<3)
 #define permCopy     (1<<4)
 #define permNotes    (1<<5)
+#define permHighResPrint (1<<11)
 #define defPermFlags 0xfffc
 #endif

 //------------------------------------------------------------------------
@@ -898,8 +900,26 @@ GBool XRef::okToPrint(GBool ignoreOwnerP
   return gTrue;
 #endif
 }

+// we can print at high res if we are only doing security handler revision
+// 2 (and we are allowed to print at all), or with security handler rev
+// 3 and we are allowed to print, and bit 12 is set.
+GBool XRef::okToPrintHighRes(GBool ignoreOwnerPW) {
+#ifndef NO_DECRYPTION
+  if (2 == encRevision) {
+    return (okToPrint(ignoreOwnerPW));
+  } else if (encRevision >= 3) {
+    return (okToPrint(ignoreOwnerPW) && (permFlags & permHighResPrint));
+  } else {
+    // something weird - unknown security handler version
+    return gFalse;
+  }
+#else
+  return gTrue;
+#endif
+}
+
 GBool XRef::okToChange(GBool ignoreOwnerPW) {
 #ifndef NO_DECRYPTION
   return (!ignoreOwnerPW && ownerPasswordOk) || (permFlags & permChange);
 #else
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/poppler/attachments/20050705/90d0a599/attachment.pgp


More information about the poppler mailing list