Commit 0a3057dc0a1b77720cf560a2644ed039dd46bd6a

Authored by Jay Berkenbilt
1 parent edc3b309

More testing for Unicode passwords

qpdf/qtest/qpdf.test
... ... @@ -3378,7 +3378,8 @@ foreach my $d (@unicode_pw_cases)
3378 3378 }
3379 3379 }
3380 3380  
3381   -$n_tests += 2;
  3381 +$n_tests += 5;
  3382 +
3382 3383 $td->runtest("bytes fallback warning",
3383 3384 {$td->COMMAND =>
3384 3385 "qpdf --encrypt \@password-bare-complex-utf8 o 128 --" .
... ... @@ -3402,6 +3403,23 @@ $td->runtest("bytes fallback warning",
3402 3403 $td->NORMALIZE_NEWLINES);
3403 3404 }
3404 3405  
  3406 +# Exercise passing Unicode passwords via the command line. This tests
  3407 +# wmain for Windows and assumes a UTF-8 locale for other platforms.
  3408 +$td->runtest("Unicode at CLI",
  3409 + {$td->COMMAND =>
  3410 + "qpdf --encrypt π ʬ 256 --" .
  3411 + " minimal.pdf a.pdf"},
  3412 + {$td->STRING => "", $td->EXIT_STATUS => 0},
  3413 + $td->NORMALIZE_NEWLINES);
  3414 +$td->runtest("Decrypt using user password",
  3415 + {$td->COMMAND => "qpdf --show-encryption a.pdf --password=π"},
  3416 + {$td->FILE => "unicode-up.out", $td->EXIT_STATUS => 0},
  3417 + $td->NORMALIZE_NEWLINES);
  3418 +$td->runtest("Decrypt using owner password",
  3419 + {$td->COMMAND => "qpdf --show-encryption a.pdf --password=ʬ"},
  3420 + {$td->FILE => "unicode-op.out", $td->EXIT_STATUS => 0},
  3421 + $td->NORMALIZE_NEWLINES);
  3422 +
3405 3423 show_ntests();
3406 3424 # ----------
3407 3425 $td->notify("--- Check from C API ---");
... ...
qpdf/qtest/qpdf/unicode-op.out 0 → 100644
  1 +R = 6
  2 +P = -4
  3 +User password =
  4 +extract for accessibility: allowed
  5 +extract for any purpose: allowed
  6 +print low resolution: allowed
  7 +print high resolution: allowed
  8 +modify document assembly: allowed
  9 +modify forms: allowed
  10 +modify annotations: allowed
  11 +modify other: allowed
  12 +modify anything: allowed
  13 +stream encryption method: AESv3
  14 +string encryption method: AESv3
  15 +file encryption method: AESv3
... ...
qpdf/qtest/qpdf/unicode-up.out 0 → 100644
  1 +R = 6
  2 +P = -4
  3 +User password = π
  4 +extract for accessibility: allowed
  5 +extract for any purpose: allowed
  6 +print low resolution: allowed
  7 +print high resolution: allowed
  8 +modify document assembly: allowed
  9 +modify forms: allowed
  10 +modify annotations: allowed
  11 +modify other: allowed
  12 +modify anything: allowed
  13 +stream encryption method: AESv3
  14 +string encryption method: AESv3
  15 +file encryption method: AESv3
... ...