aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2023-09-03 19:56:02 +0200
committerJay Berkenbilt <ejb@ql.org>2023-09-03 19:56:34 +0200
commit806922f643b05b50e423a7f16fc800dfd52ca8ef (patch)
tree16b6647d5202683ef00e92d6fded84b02fb88381
parent27980894bd91524b11ea2d43e927cfc99304e4de (diff)
downloadqpdf-806922f643b05b50e423a7f16fc800dfd52ca8ef.tar.zst
ascii85: ignore whitespace between ~ and > (fixes #973)
-rw-r--r--ChangeLog3
-rw-r--r--libqpdf/Pl_ASCII85Decoder.cc21
-rw-r--r--libtests/qtest/ascii85.test8
3 files changed, 21 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index 2389afe4..f7adf320 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2023-09-03 Jay Berkenbilt <ejb@ql.org>
+ * ascii85 parser: ignore spaces everywhere including between ~
+ and >. Fixes #973.
+
* Bug fix: with --pages, if one of the external files had warnings
but the main file did not, the warning was previously not taken
into consideration when determining the exit status.
diff --git a/libqpdf/Pl_ASCII85Decoder.cc b/libqpdf/Pl_ASCII85Decoder.cc
index fd36722a..aef8718d 100644
--- a/libqpdf/Pl_ASCII85Decoder.cc
+++ b/libqpdf/Pl_ASCII85Decoder.cc
@@ -19,6 +19,17 @@ Pl_ASCII85Decoder::write(unsigned char const* buf, size_t len)
return;
}
for (size_t i = 0; i < len; ++i) {
+ switch (buf[i]) {
+ case ' ':
+ case '\f':
+ case '\v':
+ case '\t':
+ case '\r':
+ case '\n':
+ QTC::TC("libtests", "Pl_ASCII85Decoder ignore space");
+ // ignore whitespace
+ continue;
+ }
if (eod > 1) {
break;
} else if (eod == 1) {
@@ -30,16 +41,6 @@ Pl_ASCII85Decoder::write(unsigned char const* buf, size_t len)
}
} else {
switch (buf[i]) {
- case ' ':
- case '\f':
- case '\v':
- case '\t':
- case '\r':
- case '\n':
- QTC::TC("libtests", "Pl_ASCII85Decoder ignore space");
- // ignore whitespace
- break;
-
case '~':
eod = 1;
break;
diff --git a/libtests/qtest/ascii85.test b/libtests/qtest/ascii85.test
index 53977619..1843f8a5 100644
--- a/libtests/qtest/ascii85.test
+++ b/libtests/qtest/ascii85.test
@@ -20,4 +20,10 @@ $td->runtest("partial decode",
$td->EXIT_STATUS => 0},
$td->NORMALIZE_NEWLINES);
-$td->report(2);
+$td->runtest("newline between ~ and >",
+ {$td->COMMAND => "echo '\@<5skEHbu7\$3~\n>' | ascii85"},
+ {$td->STRING => "asdfqwer\n",
+ $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
+
+$td->report(3);