diff options
Diffstat (limited to 'qpdf')
-rw-r--r-- | qpdf/qtest/many-nulls.test | 19 | ||||
-rw-r--r-- | qpdf/qtest/qpdf-json.test | 15 | ||||
-rw-r--r-- | qpdf/qtest/qpdf/minimal-nulls-1.json | 453 | ||||
-rw-r--r-- | qpdf/qtest/qpdf/minimal-nulls-2.json | 424 | ||||
-rw-r--r-- | qpdf/qtest/qpdf/minimal-nulls.pdf | 387 | ||||
-rw-r--r-- | qpdf/qtest/qpdf/weird-tokens-alt.json | 136 | ||||
-rw-r--r-- | qpdf/qtest/qpdf/weird-tokens-v1.json | 295 | ||||
-rw-r--r-- | qpdf/qtest/qpdf/weird-tokens.json | 136 | ||||
-rw-r--r-- | qpdf/qtest/qpdf/weird-tokens.pdf | 148 | ||||
-rw-r--r-- | qpdf/test_driver.cc | 18 |
10 files changed, 2018 insertions, 13 deletions
diff --git a/qpdf/qtest/many-nulls.test b/qpdf/qtest/many-nulls.test index 8a723d53..26ce5f8a 100644 --- a/qpdf/qtest/many-nulls.test +++ b/qpdf/qtest/many-nulls.test @@ -33,5 +33,22 @@ $td->runtest("copy sparse array", {$td->COMMAND => "test_driver 97 many-nulls.pdf"}, {$td->STRING => "test 97 done\n", $td->EXIT_STATUS => 0}, $td->NORMALIZE_NEWLINES); +$td->runtest("copy file with many nulls", + {$td->COMMAND => + "qpdf minimal-nulls.pdf --qdf --static-id --no-original-object-ids a.pdf"}, + {$td->STRING => "", $td->EXIT_STATUS => 0}, + $td->NORMALIZE_NEWLINES); +$td->runtest("compare files", + {$td->FILE => "a.pdf"}, + {$td->FILE => "minimal-nulls.pdf"}); +$td->runtest("file with many nulls to JSON v1", + {$td->COMMAND => "qpdf minimal-nulls.pdf --json=1 -"}, + {$td->FILE => "minimal-nulls-1.json", $td->EXIT_STATUS => 0}, + $td->NORMALIZE_NEWLINES); +$td->runtest("file with many nulls to JSON v2", + {$td->COMMAND => "qpdf minimal-nulls.pdf --json=2 -"}, + {$td->FILE => "minimal-nulls-2.json", $td->EXIT_STATUS => 0}, + $td->NORMALIZE_NEWLINES); + cleanup(); -$td->report(4); +$td->report(8); diff --git a/qpdf/qtest/qpdf-json.test b/qpdf/qtest/qpdf-json.test index 9542bccf..299bcd7e 100644 --- a/qpdf/qtest/qpdf-json.test +++ b/qpdf/qtest/qpdf-json.test @@ -350,7 +350,7 @@ $td->runtest("check C API write to JSON stream", # (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 += 4; +$n_tests += 7; $td->runtest("handle binary names", {$td->COMMAND => "qpdf --json-output weird-tokens.pdf a.json"}, @@ -371,6 +371,17 @@ $td->runtest("weird tokens with scientific notation", "qpdf --json-input --json-output weird-tokens-alt.json -"}, {$td->FILE => "weird-tokens.json", $td->EXIT_STATUS => 0}, $td->NORMALIZE_NEWLINES); - +$td->runtest("handle binary names (JSON v1)", + {$td->COMMAND => + "qpdf --json=1 weird-tokens.pdf a.json"}, + {$td->STRING => "", $td->EXIT_STATUS => 0}); +$td->runtest("check json", + {$td->FILE => "a.json"}, + {$td->FILE => "weird-tokens-v1.json"}, + $td->NORMALIZE_NEWLINES); +$td->runtest("write JSON to pipeline", + {$td->COMMAND => "test_driver 98 minimal.pdf ''"}, + {$td->STRING => "test 98 done\n", $td->EXIT_STATUS => 0}, + $td->NORMALIZE_NEWLINES); cleanup(); $td->report($n_tests); diff --git a/qpdf/qtest/qpdf/minimal-nulls-1.json b/qpdf/qtest/qpdf/minimal-nulls-1.json new file mode 100644 index 00000000..0b8f6e53 --- /dev/null +++ b/qpdf/qtest/qpdf/minimal-nulls-1.json @@ -0,0 +1,453 @@ +{ + "version": 1, + "parameters": { + "decodelevel": "generalized" + }, + "pages": [ + { + "contents": [ + "4 0 R" + ], + "images": [], + "label": null, + "object": "3 0 R", + "outlines": [], + "pageposfrom1": 1 + } + ], + "pagelabels": [], + "acroform": { + "fields": [], + "hasacroform": false, + "needappearances": false + }, + "attachments": {}, + "encrypt": { + "capabilities": { + "accessibility": true, + "extract": true, + "moddifyannotations": true, + "modify": true, + "modifyassembly": true, + "modifyforms": true, + "modifyother": true, + "printhigh": true, + "printlow": true + }, + "encrypted": false, + "ownerpasswordmatched": false, + "parameters": { + "P": 0, + "R": 0, + "V": 0, + "bits": 0, + "filemethod": "none", + "key": null, + "method": "none", + "streammethod": "none", + "stringmethod": "none" + }, + "recovereduserpassword": null, + "userpasswordmatched": false + }, + "outlines": [], + "objects": { + "1 0 R": { + "/Pages": "2 0 R", + "/Type": "/Catalog" + }, + "2 0 R": { + "/Count": 1, + "/Kids": [ + "3 0 R" + ], + "/Type": "/Pages" + }, + "3 0 R": { + "/Contents": "4 0 R", + "/MediaBox": [ + 0, + 0, + 612, + 792 + ], + "/Nulls": [ + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + "6 0 R", + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null + ], + "/Parent": "2 0 R", + "/Resources": { + "/Font": { + "/F1": "7 0 R" + }, + "/ProcSet": "8 0 R" + }, + "/Type": "/Page" + }, + "4 0 R": { + "/Length": "5 0 R" + }, + "5 0 R": 44, + "6 0 R": null, + "7 0 R": { + "/BaseFont": "/Helvetica", + "/Encoding": "/WinAnsiEncoding", + "/Name": "/F1", + "/Subtype": "/Type1", + "/Type": "/Font" + }, + "8 0 R": [ + "/PDF", + "/Text" + ], + "trailer": { + "/ID": [ + "ÏîgE�EMÛ‹Êߢ$²\u0005#", + "1AY&SXŠfi#—bd3…'Ł" + ], + "/Root": "1 0 R", + "/Size": 9 + } + }, + "objectinfo": { + "1 0 R": { + "stream": { + "filter": null, + "is": false, + "length": null + } + }, + "2 0 R": { + "stream": { + "filter": null, + "is": false, + "length": null + } + }, + "3 0 R": { + "stream": { + "filter": null, + "is": false, + "length": null + } + }, + "4 0 R": { + "stream": { + "filter": null, + "is": true, + "length": 44 + } + }, + "5 0 R": { + "stream": { + "filter": null, + "is": false, + "length": null + } + }, + "6 0 R": { + "stream": { + "filter": null, + "is": false, + "length": null + } + }, + "7 0 R": { + "stream": { + "filter": null, + "is": false, + "length": null + } + }, + "8 0 R": { + "stream": { + "filter": null, + "is": false, + "length": null + } + } + } +} diff --git a/qpdf/qtest/qpdf/minimal-nulls-2.json b/qpdf/qtest/qpdf/minimal-nulls-2.json new file mode 100644 index 00000000..6bf61ea7 --- /dev/null +++ b/qpdf/qtest/qpdf/minimal-nulls-2.json @@ -0,0 +1,424 @@ +{ + "version": 2, + "parameters": { + "decodelevel": "generalized" + }, + "pages": [ + { + "contents": [ + "4 0 R" + ], + "images": [], + "label": null, + "object": "3 0 R", + "outlines": [], + "pageposfrom1": 1 + } + ], + "pagelabels": [], + "acroform": { + "fields": [], + "hasacroform": false, + "needappearances": false + }, + "attachments": {}, + "encrypt": { + "capabilities": { + "accessibility": true, + "extract": true, + "modify": true, + "modifyannotations": true, + "modifyassembly": true, + "modifyforms": true, + "modifyother": true, + "printhigh": true, + "printlow": true + }, + "encrypted": false, + "ownerpasswordmatched": false, + "parameters": { + "P": 0, + "R": 0, + "V": 0, + "bits": 0, + "filemethod": "none", + "key": null, + "method": "none", + "streammethod": "none", + "stringmethod": "none" + }, + "recovereduserpassword": null, + "userpasswordmatched": false + }, + "outlines": [], + "qpdf": [ + { + "jsonversion": 2, + "pdfversion": "1.3", + "pushedinheritedpageresources": false, + "calledgetallpages": true, + "maxobjectid": 8 + }, + { + "obj:1 0 R": { + "value": { + "/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 + ], + "/Nulls": [ + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + "6 0 R", + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 10, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null + ], + "/Parent": "2 0 R", + "/Resources": { + "/Font": { + "/F1": "7 0 R" + }, + "/ProcSet": "8 0 R" + }, + "/Type": "/Page" + } + }, + "obj:4 0 R": { + "stream": { + "dict": { + "/Length": "5 0 R" + } + } + }, + "obj:5 0 R": { + "value": 44 + }, + "obj:6 0 R": { + "value": null + }, + "obj:7 0 R": { + "value": { + "/BaseFont": "/Helvetica", + "/Encoding": "/WinAnsiEncoding", + "/Name": "/F1", + "/Subtype": "/Type1", + "/Type": "/Font" + } + }, + "obj:8 0 R": { + "value": [ + "/PDF", + "/Text" + ] + }, + "trailer": { + "value": { + "/ID": [ + "b:cfee6745ad454ddb88cadfa224b20523", + "b:31415926535897932384626433832795" + ], + "/Root": "1 0 R", + "/Size": 9 + } + } + } + ] +} diff --git a/qpdf/qtest/qpdf/minimal-nulls.pdf b/qpdf/qtest/qpdf/minimal-nulls.pdf new file mode 100644 index 00000000..491d0b30 --- /dev/null +++ b/qpdf/qtest/qpdf/minimal-nulls.pdf @@ -0,0 +1,387 @@ +%PDF-1.3 +% +%QDF-1.0 + +1 0 obj +<< + /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 + ] + /Nulls [ + null + null + null + null + null + null + null + null + null + null + 6 0 R + null + null + null + null + null + null + null + null + null + null + 10 + null + null + null + null + null + null + null + null + null + null + 10 + null + null + null + null + null + null + null + null + null + null + 10 + null + null + null + null + null + null + null + null + null + null + 10 + null + null + null + null + null + null + null + null + null + null + 10 + null + null + null + null + null + null + null + null + null + null + 10 + null + null + null + null + null + null + null + null + null + null + 10 + null + null + null + null + null + null + null + null + null + null + 10 + null + null + null + null + null + null + null + null + null + null + 10 + null + null + null + null + null + null + null + null + null + null + 10 + null + null + null + null + null + null + null + null + null + null + 10 + null + null + null + null + null + null + null + null + null + null + 10 + null + null + null + null + null + null + null + null + null + null + 10 + null + null + null + null + null + null + null + null + null + null + 10 + null + null + null + null + null + null + null + null + null + null + 10 + null + null + null + null + null + null + null + null + null + null + 10 + null + null + null + null + null + null + null + null + null + null + 10 + null + null + null + null + null + null + null + null + null + null + 10 + null + null + null + null + null + null + null + null + null + null + 10 + null + null + null + null + null + null + null + null + null + null + 10 + null + null + null + null + null + null + null + null + null + null + 10 + null + null + null + null + null + null + null + null + null + null + 10 + null + null + null + null + null + null + null + null + null + null + 10 + null + null + null + null + null + null + null + null + null + null + 10 + null + null + null + null + null + null + null + null + null + null + ] + /Parent 2 0 R + /Resources << + /Font << + /F1 7 0 R + >> + /ProcSet 8 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 +null +endobj + +7 0 obj +<< + /BaseFont /Helvetica + /Encoding /WinAnsiEncoding + /Name /F1 + /Subtype /Type1 + /Type /Font +>> +endobj + +8 0 obj +[ + /PDF + /Text +] +endobj + +xref +0 9 +0000000000 65535 f +0000000025 00000 n +0000000079 00000 n +0000000161 00000 n +0000002909 00000 n +0000003008 00000 n +0000003027 00000 n +0000003048 00000 n +0000003166 00000 n +trailer << + /Root 1 0 R + /Size 9 + /ID [<cfee6745ad454ddb88cadfa224b20523><31415926535897932384626433832795>] +>> +startxref +3201 +%%EOF diff --git a/qpdf/qtest/qpdf/weird-tokens-alt.json b/qpdf/qtest/qpdf/weird-tokens-alt.json index 607bdd55..7fbff908 100644 --- a/qpdf/qtest/qpdf/weird-tokens-alt.json +++ b/qpdf/qtest/qpdf/weird-tokens-alt.json @@ -10,21 +10,155 @@ { "obj:1 0 R": { "value": { + "/Escape\\Key": 42, "/Extra": [ "u:Names with binary data", "n:/ABCDEF+#ba#da#cc#e5", "n:/OVERLONG+#c0#81", + "n:/OVERLONG+#c1#ff", + "/Ok+", "n:/OVERLONG+#e0#81#82", + "n:/OVERLONG+#e0#9f#ff", + "/Ok+ࠀ", "n:/OVERLONG+#f0#81#82#83", + "n:/OVERLONG+#f0#8f#ff#ff", + "/Ok+𐀀", "n:/range+#01", "n:/low+#18", "/ABCEDEF+π", "n:/one+#a0two", "n:/text#2fplain", + "u:Names requiring escaping in JSON", + "/Back\\shlash", + "/Low\u0022", + "/Low\u001f", + "/ExceptSpace ", + "/Except!", "u:Very small/large reals", 1e-05, 1e12 ], + "/Nested": { + "/1": { + "/2": { + "/3": { + "/4": { + "/5": { + "/6": { + "/7": { + "/8": { + "/9": { + "/10": { + "/1": { + "/2": { + "/3": { + "/4": { + "/5": { + "/6": { + "/7": { + "/8": { + "/9": { + "/10": { + "/1": { + "/2": { + "/3": { + "/4": { + "/5": { + "/6": { + "/7": { + "/8": { + "/9": { + "/10": { + "/1": { + "/2": { + "/3": { + "/4": { + "/5": { + "/6": { + "/7": { + "/8": { + "/9": { + "/10": { + "/1": { + "/2": { + "/3": { + "/4": { + "/5": { + "/6": { + "/7": { + "/8": { + "/9": { + "/10": { + "/1": { + "/2": { + "/3": { + "/4": { + "/5": { + "/6": { + "/7": { + "/8": { + "/9": { + "/10": 42 + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + }, "/Pages": "2 0 R", "/Type": "/Catalog", "n:/WeirdKey+#ba#da#cc#e5": 42 @@ -78,7 +212,7 @@ "value": { "/ID": [ "b:42841c13bbf709d79a200fa1691836f8", - "b:728c020f464c3cf7e02c12605fa7d88b" + "b:31415926535897932384626433832795" ], "/Root": "1 0 R", "/Size": 7 diff --git a/qpdf/qtest/qpdf/weird-tokens-v1.json b/qpdf/qtest/qpdf/weird-tokens-v1.json new file mode 100644 index 00000000..8b8c194c --- /dev/null +++ b/qpdf/qtest/qpdf/weird-tokens-v1.json @@ -0,0 +1,295 @@ +{ + "version": 1, + "parameters": { + "decodelevel": "generalized" + }, + "pages": [ + { + "contents": [ + "4 0 R" + ], + "images": [], + "label": null, + "object": "3 0 R", + "outlines": [], + "pageposfrom1": 1 + } + ], + "pagelabels": [], + "acroform": { + "fields": [], + "hasacroform": false, + "needappearances": false + }, + "attachments": {}, + "encrypt": { + "capabilities": { + "accessibility": true, + "extract": true, + "moddifyannotations": true, + "modify": true, + "modifyassembly": true, + "modifyforms": true, + "modifyother": true, + "printhigh": true, + "printlow": true + }, + "encrypted": false, + "ownerpasswordmatched": false, + "parameters": { + "P": 0, + "R": 0, + "V": 0, + "bits": 0, + "filemethod": "none", + "key": null, + "method": "none", + "streammethod": "none", + "stringmethod": "none" + }, + "recovereduserpassword": null, + "userpasswordmatched": false + }, + "outlines": [], + "objects": { + "1 0 R": { + "/Escape\\Key": 42, + "/Extra": [ + "Names with binary data", + "/ABCDEF+#ba#da#cc#e5", + "/OVERLONG+#c0#81", + "/OVERLONG+#c1#ff", + "/Ok+#c2#80", + "/OVERLONG+#e0#81#82", + "/OVERLONG+#e0#9f#ff", + "/Ok+#e0#a0#80", + "/OVERLONG+#f0#81#82#83", + "/OVERLONG+#f0#8f#ff#ff", + "/Ok+#f0#90#80#80", + "/range+#01", + "/low+#18", + "/ABCEDEF+#cf#80", + "/one+#a0two", + "/text#2fplain", + "Names requiring escaping in JSON", + "/Back\\shlash", + "/Low\"", + "/Low#1f", + "/ExceptSpace#20", + "/Except!", + "Very small/large reals", + 0.00001, + 1000000000000 + ], + "/Nested": { + "/1": { + "/2": { + "/3": { + "/4": { + "/5": { + "/6": { + "/7": { + "/8": { + "/9": { + "/10": { + "/1": { + "/2": { + "/3": { + "/4": { + "/5": { + "/6": { + "/7": { + "/8": { + "/9": { + "/10": { + "/1": { + "/2": { + "/3": { + "/4": { + "/5": { + "/6": { + "/7": { + "/8": { + "/9": { + "/10": { + "/1": { + "/2": { + "/3": { + "/4": { + "/5": { + "/6": { + "/7": { + "/8": { + "/9": { + "/10": { + "/1": { + "/2": { + "/3": { + "/4": { + "/5": { + "/6": { + "/7": { + "/8": { + "/9": { + "/10": { + "/1": { + "/2": { + "/3": { + "/4": { + "/5": { + "/6": { + "/7": { + "/8": { + "/9": { + "/10": 42 + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + }, + "/Pages": "2 0 R", + "/Type": "/Catalog", + "/WeirdKey+#ba#da#cc#e5": 42 + }, + "2 0 R": { + "/Count": 1, + "/Kids": [ + "3 0 R" + ], + "/Type": "/Pages" + }, + "3 0 R": { + "/Contents": "4 0 R", + "/MediaBox": [ + 0, + 0, + 612, + 792 + ], + "/Parent": "2 0 R", + "/Resources": { + "/Font": { + "/F1": "6 0 R" + } + }, + "/Type": "/Page" + }, + "4 0 R": { + "/Length": "5 0 R" + }, + "5 0 R": 44, + "6 0 R": { + "/BaseFont": "/Helvetica", + "/Encoding": "/WinAnsiEncoding", + "/Subtype": "/Type1", + "/Type": "/Font" + }, + "trailer": { + "/ID": [ + "B—˝\u0013»÷\t×ı \u000f¡i˘6ø", + "1AY&SXŠfi#—bd3…'Ł" + ], + "/Root": "1 0 R", + "/Size": 7 + } + }, + "objectinfo": { + "1 0 R": { + "stream": { + "filter": null, + "is": false, + "length": null + } + }, + "2 0 R": { + "stream": { + "filter": null, + "is": false, + "length": null + } + }, + "3 0 R": { + "stream": { + "filter": null, + "is": false, + "length": null + } + }, + "4 0 R": { + "stream": { + "filter": null, + "is": true, + "length": 44 + } + }, + "5 0 R": { + "stream": { + "filter": null, + "is": false, + "length": null + } + }, + "6 0 R": { + "stream": { + "filter": null, + "is": false, + "length": null + } + } + } +} diff --git a/qpdf/qtest/qpdf/weird-tokens.json b/qpdf/qtest/qpdf/weird-tokens.json index 6aca6a5a..4ad926e7 100644 --- a/qpdf/qtest/qpdf/weird-tokens.json +++ b/qpdf/qtest/qpdf/weird-tokens.json @@ -10,21 +10,155 @@ { "obj:1 0 R": { "value": { + "/Escape\\Key": 42, "/Extra": [ "u:Names with binary data", "n:/ABCDEF+#ba#da#cc#e5", "n:/OVERLONG+#c0#81", + "n:/OVERLONG+#c1#ff", + "/Ok+", "n:/OVERLONG+#e0#81#82", + "n:/OVERLONG+#e0#9f#ff", + "/Ok+ࠀ", "n:/OVERLONG+#f0#81#82#83", + "n:/OVERLONG+#f0#8f#ff#ff", + "/Ok+𐀀", "/range+\u0001", "/low+\u0018", "/ABCEDEF+π", "n:/one+#a0two", "/text/plain", + "u:Names requiring escaping in JSON", + "/Back\\shlash", + "/Low\"", + "/Low\u001f", + "/ExceptSpace ", + "/Except!", "u:Very small/large reals", 0.00001, 1000000000000 ], + "/Nested": { + "/1": { + "/2": { + "/3": { + "/4": { + "/5": { + "/6": { + "/7": { + "/8": { + "/9": { + "/10": { + "/1": { + "/2": { + "/3": { + "/4": { + "/5": { + "/6": { + "/7": { + "/8": { + "/9": { + "/10": { + "/1": { + "/2": { + "/3": { + "/4": { + "/5": { + "/6": { + "/7": { + "/8": { + "/9": { + "/10": { + "/1": { + "/2": { + "/3": { + "/4": { + "/5": { + "/6": { + "/7": { + "/8": { + "/9": { + "/10": { + "/1": { + "/2": { + "/3": { + "/4": { + "/5": { + "/6": { + "/7": { + "/8": { + "/9": { + "/10": { + "/1": { + "/2": { + "/3": { + "/4": { + "/5": { + "/6": { + "/7": { + "/8": { + "/9": { + "/10": 42 + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + }, "/Pages": "2 0 R", "/Type": "/Catalog", "n:/WeirdKey+#ba#da#cc#e5": 42 @@ -78,7 +212,7 @@ "value": { "/ID": [ "b:42841c13bbf709d79a200fa1691836f8", - "b:728c020f464c3cf7e02c12605fa7d88b" + "b:31415926535897932384626433832795" ], "/Root": "1 0 R", "/Size": 7 diff --git a/qpdf/qtest/qpdf/weird-tokens.pdf b/qpdf/qtest/qpdf/weird-tokens.pdf index 27415a46..c49a046f 100644 --- a/qpdf/qtest/qpdf/weird-tokens.pdf +++ b/qpdf/qtest/qpdf/weird-tokens.pdf @@ -4,21 +4,155 @@ 1 0 obj << + /Escape\Key 42 /Extra [ (Names with binary data) /ABCDEF+#ba#da#cc#e5 /OVERLONG+#c0#81 + /OVERLONG+#c1#ff + /Ok+#c2#80 /OVERLONG+#e0#81#82 + /OVERLONG+#e0#9f#ff + /Ok+#e0#a0#80 /OVERLONG+#f0#81#82#83 + /OVERLONG+#f0#8f#ff#ff + /Ok+#f0#90#80#80 /range+#01 /low+#18 /ABCEDEF+#cf#80 /one+#a0two /text#2fplain + (Names requiring escaping in JSON) + /Back\shlash + /Low" + /Low#1f + /ExceptSpace#20 + /Except! (Very small/large reals) 0.00001 1000000000000 ] + /Nested << + /1 << + /2 << + /3 << + /4 << + /5 << + /6 << + /7 << + /8 << + /9 << + /10 << + /1 << + /2 << + /3 << + /4 << + /5 << + /6 << + /7 << + /8 << + /9 << + /10 << + /1 << + /2 << + /3 << + /4 << + /5 << + /6 << + /7 << + /8 << + /9 << + /10 << + /1 << + /2 << + /3 << + /4 << + /5 << + /6 << + /7 << + /8 << + /9 << + /10 << + /1 << + /2 << + /3 << + /4 << + /5 << + /6 << + /7 << + /8 << + /9 << + /10 << + /1 << + /2 << + /3 << + /4 << + /5 << + /6 << + /7 << + /8 << + /9 << + /10 42 + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> /Pages 2 0 R /Type /Catalog /WeirdKey+#ba#da#cc#e5 42 @@ -86,16 +220,16 @@ xref 0 7 0000000000 65535 f 0000000025 00000 n -0000000389 00000 n -0000000471 00000 n -0000000667 00000 n -0000000766 00000 n -0000000785 00000 n +0000008642 00000 n +0000008724 00000 n +0000008920 00000 n +0000009019 00000 n +0000009038 00000 n trailer << /Root 1 0 R /Size 7 - /ID [<42841c13bbf709d79a200fa1691836f8><728c020f464c3cf7e02c12605fa7d88b>] + /ID [<42841c13bbf709d79a200fa1691836f8><31415926535897932384626433832795>] >> startxref -891 +9144 %%EOF diff --git a/qpdf/test_driver.cc b/qpdf/test_driver.cc index e7451576..565b517d 100644 --- a/qpdf/test_driver.cc +++ b/qpdf/test_driver.cc @@ -3382,6 +3382,22 @@ test_97(QPDF& pdf, char const* arg2) assert(nulls.unparse() == nulls2.unparse()); } +static void +test_98(QPDF& pdf, char const* arg2) +{ + // Test QPDFObjectHandle::writeJSON. This test is built for minimal.pdf. + for (int i = 1; i < 7; ++i) { + auto oh = pdf.getObject(i, 0); + Pl_Buffer bf1{"write", nullptr}; + Pl_Buffer bf2{"get", nullptr}; + oh.writeJSON(JSON::LATEST, &bf1, true, 7); + bf1.finish(); + oh.getJSON(JSON::LATEST, true).write(&bf2, 7); + bf2.finish(); + assert(bf1.getString() == bf2.getString()); + } +} + void runtest(int n, char const* filename1, char const* arg2) { @@ -3483,7 +3499,7 @@ runtest(int n, char const* filename1, char const* arg2) {78, test_78}, {79, test_79}, {80, test_80}, {81, test_81}, {82, test_82}, {83, test_83}, {84, test_84}, {85, test_85}, {86, test_86}, {87, test_87}, {88, test_88}, {89, test_89}, {90, test_90}, {91, test_91}, {92, test_92}, {93, test_93}, {94, test_94}, {95, test_95}, - {96, test_96}, {97, test_97}}; + {96, test_96}, {97, test_97}, {98, test_98}}; auto fn = test_functions.find(n); if (fn == test_functions.end()) { |