aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2019-01-19 20:11:53 +0100
committerJay Berkenbilt <ejb@ql.org>2019-01-19 20:16:03 +0100
commit0a3057dc0a1b77720cf560a2644ed039dd46bd6a (patch)
tree127a6a51324faae70a0654f9e7beaee8b6000cfe
parentedc3b309bce1f9aed383a4911ff7ea5b6bb7c9e9 (diff)
downloadqpdf-0a3057dc0a1b77720cf560a2644ed039dd46bd6a.tar.zst
More testing for Unicode passwords
-rw-r--r--qpdf/qtest/qpdf.test20
-rw-r--r--qpdf/qtest/qpdf/unicode-op.out15
-rw-r--r--qpdf/qtest/qpdf/unicode-up.out15
3 files changed, 49 insertions, 1 deletions
diff --git a/qpdf/qtest/qpdf.test b/qpdf/qtest/qpdf.test
index 1ccd4d12..a31d463d 100644
--- a/qpdf/qtest/qpdf.test
+++ b/qpdf/qtest/qpdf.test
@@ -3378,7 +3378,8 @@ foreach my $d (@unicode_pw_cases)
}
}
-$n_tests += 2;
+$n_tests += 5;
+
$td->runtest("bytes fallback warning",
{$td->COMMAND =>
"qpdf --encrypt \@password-bare-complex-utf8 o 128 --" .
@@ -3402,6 +3403,23 @@ $td->runtest("bytes fallback warning",
$td->NORMALIZE_NEWLINES);
}
+# Exercise passing Unicode passwords via the command line. This tests
+# wmain for Windows and assumes a UTF-8 locale for other platforms.
+$td->runtest("Unicode at CLI",
+ {$td->COMMAND =>
+ "qpdf --encrypt π ʬ 256 --" .
+ " minimal.pdf a.pdf"},
+ {$td->STRING => "", $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
+$td->runtest("Decrypt using user password",
+ {$td->COMMAND => "qpdf --show-encryption a.pdf --password=π"},
+ {$td->FILE => "unicode-up.out", $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
+$td->runtest("Decrypt using owner password",
+ {$td->COMMAND => "qpdf --show-encryption a.pdf --password=ʬ"},
+ {$td->FILE => "unicode-op.out", $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
+
show_ntests();
# ----------
$td->notify("--- Check from C API ---");
diff --git a/qpdf/qtest/qpdf/unicode-op.out b/qpdf/qtest/qpdf/unicode-op.out
new file mode 100644
index 00000000..a1437ca4
--- /dev/null
+++ b/qpdf/qtest/qpdf/unicode-op.out
@@ -0,0 +1,15 @@
+R = 6
+P = -4
+User password =
+extract for accessibility: allowed
+extract for any purpose: allowed
+print low resolution: allowed
+print high resolution: allowed
+modify document assembly: allowed
+modify forms: allowed
+modify annotations: allowed
+modify other: allowed
+modify anything: allowed
+stream encryption method: AESv3
+string encryption method: AESv3
+file encryption method: AESv3
diff --git a/qpdf/qtest/qpdf/unicode-up.out b/qpdf/qtest/qpdf/unicode-up.out
new file mode 100644
index 00000000..9e3a0581
--- /dev/null
+++ b/qpdf/qtest/qpdf/unicode-up.out
@@ -0,0 +1,15 @@
+R = 6
+P = -4
+User password = π
+extract for accessibility: allowed
+extract for any purpose: allowed
+print low resolution: allowed
+print high resolution: allowed
+modify document assembly: allowed
+modify forms: allowed
+modify annotations: allowed
+modify other: allowed
+modify anything: allowed
+stream encryption method: AESv3
+string encryption method: AESv3
+file encryption method: AESv3