Commit 806922f643b05b50e423a7f16fc800dfd52ca8ef

Authored by Jay Berkenbilt
1 parent 27980894

ascii85: ignore whitespace between ~ and > (fixes #973)

ChangeLog
1 2023-09-03 Jay Berkenbilt <ejb@ql.org> 1 2023-09-03 Jay Berkenbilt <ejb@ql.org>
2 2
  3 + * ascii85 parser: ignore spaces everywhere including between ~
  4 + and >. Fixes #973.
  5 +
3 * Bug fix: with --pages, if one of the external files had warnings 6 * Bug fix: with --pages, if one of the external files had warnings
4 but the main file did not, the warning was previously not taken 7 but the main file did not, the warning was previously not taken
5 into consideration when determining the exit status. 8 into consideration when determining the exit status.
libqpdf/Pl_ASCII85Decoder.cc
@@ -19,6 +19,17 @@ Pl_ASCII85Decoder::write(unsigned char const* buf, size_t len) @@ -19,6 +19,17 @@ Pl_ASCII85Decoder::write(unsigned char const* buf, size_t len)
19 return; 19 return;
20 } 20 }
21 for (size_t i = 0; i < len; ++i) { 21 for (size_t i = 0; i < len; ++i) {
  22 + switch (buf[i]) {
  23 + case ' ':
  24 + case '\f':
  25 + case '\v':
  26 + case '\t':
  27 + case '\r':
  28 + case '\n':
  29 + QTC::TC("libtests", "Pl_ASCII85Decoder ignore space");
  30 + // ignore whitespace
  31 + continue;
  32 + }
22 if (eod > 1) { 33 if (eod > 1) {
23 break; 34 break;
24 } else if (eod == 1) { 35 } else if (eod == 1) {
@@ -30,16 +41,6 @@ Pl_ASCII85Decoder::write(unsigned char const* buf, size_t len) @@ -30,16 +41,6 @@ Pl_ASCII85Decoder::write(unsigned char const* buf, size_t len)
30 } 41 }
31 } else { 42 } else {
32 switch (buf[i]) { 43 switch (buf[i]) {
33 - case ' ':  
34 - case '\f':  
35 - case '\v':  
36 - case '\t':  
37 - case '\r':  
38 - case '\n':  
39 - QTC::TC("libtests", "Pl_ASCII85Decoder ignore space");  
40 - // ignore whitespace  
41 - break;  
42 -  
43 case '~': 44 case '~':
44 eod = 1; 45 eod = 1;
45 break; 46 break;
libtests/qtest/ascii85.test
@@ -20,4 +20,10 @@ $td-&gt;runtest(&quot;partial decode&quot;, @@ -20,4 +20,10 @@ $td-&gt;runtest(&quot;partial decode&quot;,
20 $td->EXIT_STATUS => 0}, 20 $td->EXIT_STATUS => 0},
21 $td->NORMALIZE_NEWLINES); 21 $td->NORMALIZE_NEWLINES);
22 22
23 -$td->report(2); 23 +$td->runtest("newline between ~ and >",
  24 + {$td->COMMAND => "echo '\@<5skEHbu7\$3~\n>' | ascii85"},
  25 + {$td->STRING => "asdfqwer\n",
  26 + $td->EXIT_STATUS => 0},
  27 + $td->NORMALIZE_NEWLINES);
  28 +
  29 +$td->report(3);