diff options
Diffstat (limited to 'qpdf')
-rw-r--r-- | qpdf/qtest/qpdf-json.test | 17 | ||||
-rw-r--r-- | qpdf/qtest/qpdf/weird-tokens.json | 83 | ||||
-rw-r--r-- | qpdf/qtest/qpdf/weird-tokens.pdf | 95 |
3 files changed, 195 insertions, 0 deletions
diff --git a/qpdf/qtest/qpdf-json.test b/qpdf/qtest/qpdf-json.test index 961b507a..9691d995 100644 --- a/qpdf/qtest/qpdf-json.test +++ b/qpdf/qtest/qpdf-json.test @@ -61,6 +61,7 @@ my @goodfiles = ( 'form-fields-and-annotations.pdf', 'need-appearances.pdf', 'fxo-blue.pdf', + 'weird-tokens.pdf', ); $n_tests += 6 * scalar(@goodfiles); @@ -341,5 +342,21 @@ $td->runtest("check C API write to JSON stream", {$td->FILE => "auto-4"}, {$td->FILE => "qpdf-ctest-47-4"}); +# Bugs #1072 and #1079 illustrate cases that qpdf-json got wrong. In +# #1072, it was noticed that name tokens containing binary characters +# (using #xx) would generate invalid JSON, even though qpdf's own JSON +# parser would accept it. Also, the JSON spec allows real numbers in +# scientific notation, but the PDF spec does not. +$n_tests += 2; +$td->runtest("handle binary names", + {$td->COMMAND => + "qpdf --json-output weird-tokens.pdf a.json"}, + {$td->STRING => "", $td->EXIT_STATUS => 0}); +# Round-trip is tested above. +$td->runtest("check json", + {$td->FILE => "a.json"}, + {$td->FILE => "weird-tokens.json"}, + $td->NORMALIZE_NEWLINES); + cleanup(); $td->report($n_tests); diff --git a/qpdf/qtest/qpdf/weird-tokens.json b/qpdf/qtest/qpdf/weird-tokens.json new file mode 100644 index 00000000..66f0ff06 --- /dev/null +++ b/qpdf/qtest/qpdf/weird-tokens.json @@ -0,0 +1,83 @@ +{ + "qpdf": [ + { + "jsonversion": 2, + "pdfversion": "2.0", + "pushedinheritedpageresources": false, + "calledgetallpages": false, + "maxobjectid": 6 + }, + { + "obj:1 0 R": { + "value": { + "/Extra": [ + "u:Names with binary data", + "n:/ABCDEF+#ba#da#cc#e5", + "/ABCEDEF+Ï€", + "n:/one+#a0two", + "/text/plain", + "u:Very small/large reals", + 0.00001, + 1000000000000 + ], + "/Pages": "2 0 R", + "/Type": "/Catalog" + } + }, + "obj:2 0 R": { + "value": { + "/Count": 1, + "/Kids": [ + "3 0 R" + ], + "/Type": "/Pages" + } + }, + "obj:3 0 R": { + "value": { + "/Contents": "4 0 R", + "/MediaBox": [ + 0, + 0, + 612, + 792 + ], + "/Parent": "2 0 R", + "/Resources": { + "/Font": { + "/F1": "6 0 R" + } + }, + "/Type": "/Page" + } + }, + "obj:4 0 R": { + "stream": { + "data": "QlQKICAvRjEgMjQgVGYKICA3MiA3MjAgVGQKICAoUG90YXRvKSBUagpFVAo=", + "dict": {} + } + }, + "obj:5 0 R": { + "value": 44 + }, + "obj:6 0 R": { + "value": { + "/BaseFont": "/Helvetica", + "/Encoding": "/WinAnsiEncoding", + "/Subtype": "/Type1", + "/Type": "/Font" + } + }, + "trailer": { + "value": { + "/ID": [ + "b:42841c13bbf709d79a200fa1691836f8", + "b:728c020f464c3cf7e02c12605fa7d88b" + ], + "/Root": "1 0 R", + "/Size": 7 + } + } + } + ] +} diff --git a/qpdf/qtest/qpdf/weird-tokens.pdf b/qpdf/qtest/qpdf/weird-tokens.pdf new file mode 100644 index 00000000..7c645df3 --- /dev/null +++ b/qpdf/qtest/qpdf/weird-tokens.pdf @@ -0,0 +1,95 @@ +%PDF-2.0 +%¿÷¢þ +%QDF-1.0 + +1 0 obj +<< + /Extra [ + (Names with binary data) + /ABCDEF+#ba#da#cc#e5 + /ABCEDEF+#cf#80 + /one+#a0two + /text#2fplain + (Very small/large reals) + 0.00001 + 1000000000000 + ] + /Pages 2 0 R + /Type /Catalog +>> +endobj + +2 0 obj +<< + /Count 1 + /Kids [ + 3 0 R + ] + /Type /Pages +>> +endobj + +%% Page 1 +3 0 obj +<< + /Contents 4 0 R + /MediaBox [ + 0 + 0 + 612 + 792 + ] + /Parent 2 0 R + /Resources << + /Font << + /F1 6 0 R + >> + >> + /Type /Page +>> +endobj + +%% Contents for page 1 +4 0 obj +<< + /Length 5 0 R +>> +stream +BT + /F1 24 Tf + 72 720 Td + (Potato) Tj +ET +endstream +endobj + +5 0 obj +44 +endobj + +6 0 obj +<< + /BaseFont /Helvetica + /Encoding /WinAnsiEncoding + /Subtype /Type1 + /Type /Font +>> +endobj + +xref +0 7 +0000000000 65535 f +0000000025 00000 n +0000000261 00000 n +0000000343 00000 n +0000000539 00000 n +0000000638 00000 n +0000000657 00000 n +trailer << + /Root 1 0 R + /Size 7 + /ID [<42841c13bbf709d79a200fa1691836f8><728c020f464c3cf7e02c12605fa7d88b>] +>> +startxref +763 +%%EOF |