-
Notifications
You must be signed in to change notification settings - Fork 1
/
fix_double_pw_prompt_bug
47 lines (40 loc) · 1.58 KB
/
fix_double_pw_prompt_bug
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Description: Support PROMPT for user_pw and owner_pw simultaneously
The check if user_pw is not equal to owner_pw should be after prompting for them.
Author: Johann Felix Soden <[email protected]>
Bug-Debian: http://bugs.debian.org/614071
--- a/pdftk/pdftk.cc
+++ b/pdftk/pdftk.cc
@@ -1720,7 +1720,7 @@
case output_owner_pw_e: {
if( m_output_owner_pw.empty() ) {
- if( m_output_user_pw!= argv[ii] ) {
+ if( m_output_user_pw!= argv[ii] || strcmp(argv[ii], "PROMPT")== 0 ) {
m_output_owner_pw= argv[ii];
}
else { // error: identical user and owner password
@@ -1751,7 +1751,7 @@
case output_user_pw_e: {
if( m_output_user_pw.empty() ) {
- if( m_output_owner_pw!= argv[ii] ) {
+ if( m_output_owner_pw!= argv[ii] || strcmp( argv[ii], "PROMPT" )== 0 ) {
m_output_user_pw= argv[ii];
}
else { // error: identical user and owner password
@@ -2585,6 +2585,19 @@
}
*/
+ if( !m_output_user_pw.empty() && m_output_user_pw== m_output_owner_pw ) {
+ // error: identical user and owner password
+ // are interpreted by Acrobat (per the spec.) that
+ // the doc has no owner password
+ cerr << "Error: The user and owner passwords are the same." << endl;
+ cerr << " PDF Viewers interpret this to mean your PDF has" << endl;
+ cerr << " no owner password, so they must be different." << endl;
+ cerr << " Or, supply no owner password to pdftk if this is" << endl;
+ cerr << " what you desire." << endl;
+ cerr << "Exiting." << endl;
+ return false;
+ }
+
// un/compress output streams?
if( m_output_uncompress_b ) {