Commit 15272662f632c627c278721673df5f999df39bcd
1 parent
1bc8abfd
Fix typo in json output key name
moddify -> modify. Also carefully spell checked all remaining keys by splitting them into words and running a spell checker, not just relying on visual proofreading. That was the only one.
Showing
4 changed files
with
12 additions
and
10 deletions
TODO
| @@ -61,8 +61,6 @@ General things to remember: | @@ -61,8 +61,6 @@ General things to remember: | ||
| 61 | * The choices for json_key (job.yml) will be different for v1 and v2. | 61 | * The choices for json_key (job.yml) will be different for v1 and v2. |
| 62 | That information is already duplicated in multiple places. | 62 | That information is already duplicated in multiple places. |
| 63 | 63 | ||
| 64 | -* Remember typo: search for "Typo" In QPDFJob::doJSONEncrypt. | ||
| 65 | - | ||
| 66 | * Test stream with invalid data | 64 | * Test stream with invalid data |
| 67 | 65 | ||
| 68 | * Consider using camelCase in multi-word key names to be consistent | 66 | * Consider using camelCase in multi-word key names to be consistent |
include/qpdf/QPDFJob.hh
| @@ -445,7 +445,7 @@ class QPDFJob | @@ -445,7 +445,7 @@ class QPDFJob | ||
| 445 | 445 | ||
| 446 | // Helper functions | 446 | // Helper functions |
| 447 | static void usage(std::string const& msg); | 447 | static void usage(std::string const& msg); |
| 448 | - static JSON json_schema(std::set<std::string>* keys = 0); | 448 | + static JSON json_schema(int json_version, std::set<std::string>* keys = 0); |
| 449 | static void parse_object_id( | 449 | static void parse_object_id( |
| 450 | std::string const& objspec, bool& trailer, int& obj, int& gen); | 450 | std::string const& objspec, bool& trailer, int& obj, int& gen); |
| 451 | void parseRotationParameter(std::string const&); | 451 | void parseRotationParameter(std::string const&); |
libqpdf/QPDFJob.cc
| @@ -1374,10 +1374,12 @@ QPDFJob::doJSONEncrypt(Pipeline* p, bool& first, QPDF& pdf) | @@ -1374,10 +1374,12 @@ QPDFJob::doJSONEncrypt(Pipeline* p, bool& first, QPDF& pdf) | ||
| 1374 | "modifyassembly", JSON::makeBool(pdf.allowModifyAssembly())); | 1374 | "modifyassembly", JSON::makeBool(pdf.allowModifyAssembly())); |
| 1375 | j_capabilities.addDictionaryMember( | 1375 | j_capabilities.addDictionaryMember( |
| 1376 | "modifyforms", JSON::makeBool(pdf.allowModifyForm())); | 1376 | "modifyforms", JSON::makeBool(pdf.allowModifyForm())); |
| 1377 | - // Typo will be fixed for json v2 | ||
| 1378 | /* cSpell:ignore moddifyannotations */ | 1377 | /* cSpell:ignore moddifyannotations */ |
| 1378 | + std::string MODIFY_ANNOTATIONS = | ||
| 1379 | + (this->m->json_version == 1 ? "moddifyannotations" | ||
| 1380 | + : "modifyannotations"); | ||
| 1379 | j_capabilities.addDictionaryMember( | 1381 | j_capabilities.addDictionaryMember( |
| 1380 | - "moddifyannotations", JSON::makeBool(pdf.allowModifyAnnotation())); | 1382 | + MODIFY_ANNOTATIONS, JSON::makeBool(pdf.allowModifyAnnotation())); |
| 1381 | j_capabilities.addDictionaryMember( | 1383 | j_capabilities.addDictionaryMember( |
| 1382 | "modifyother", JSON::makeBool(pdf.allowModifyOther())); | 1384 | "modifyother", JSON::makeBool(pdf.allowModifyOther())); |
| 1383 | j_capabilities.addDictionaryMember( | 1385 | j_capabilities.addDictionaryMember( |
| @@ -1448,7 +1450,7 @@ QPDFJob::doJSONAttachments(Pipeline* p, bool& first, QPDF& pdf) | @@ -1448,7 +1450,7 @@ QPDFJob::doJSONAttachments(Pipeline* p, bool& first, QPDF& pdf) | ||
| 1448 | } | 1450 | } |
| 1449 | 1451 | ||
| 1450 | JSON | 1452 | JSON |
| 1451 | -QPDFJob::json_schema(std::set<std::string>* keys) | 1453 | +QPDFJob::json_schema(int json_version, std::set<std::string>* keys) |
| 1452 | { | 1454 | { |
| 1453 | // Style: use all lower-case keys with no dashes or underscores. | 1455 | // Style: use all lower-case keys with no dashes or underscores. |
| 1454 | // Choose array or dictionary based on indexing. For example, we | 1456 | // Choose array or dictionary based on indexing. For example, we |
| @@ -1585,12 +1587,14 @@ QPDFJob::json_schema(std::set<std::string>* keys) | @@ -1585,12 +1587,14 @@ QPDFJob::json_schema(std::set<std::string>* keys) | ||
| 1585 | "needappearances": "whether the form fields' appearance streams need to be regenerated" | 1587 | "needappearances": "whether the form fields' appearance streams need to be regenerated" |
| 1586 | })")); | 1588 | })")); |
| 1587 | } | 1589 | } |
| 1590 | + std::string MODIFY_ANNOTATIONS = | ||
| 1591 | + (json_version == 1 ? "moddifyannotations" : "modifyannotations"); | ||
| 1588 | if (all_keys || keys->count("encrypt")) { | 1592 | if (all_keys || keys->count("encrypt")) { |
| 1589 | JSON encrypt = schema.addDictionaryMember("encrypt", JSON::parse(R"({ | 1593 | JSON encrypt = schema.addDictionaryMember("encrypt", JSON::parse(R"({ |
| 1590 | "capabilities": { | 1594 | "capabilities": { |
| 1591 | "accessibility": "allow extraction for accessibility?", | 1595 | "accessibility": "allow extraction for accessibility?", |
| 1592 | "extract": "allow extraction?", | 1596 | "extract": "allow extraction?", |
| 1593 | - "moddifyannotations": "allow modifying annotations?", | 1597 | + ")" + MODIFY_ANNOTATIONS + R"(": "allow modifying annotations?", |
| 1594 | "modify": "allow all modifications?", | 1598 | "modify": "allow all modifications?", |
| 1595 | "modifyassembly": "allow modifying document assembly?", | 1599 | "modifyassembly": "allow modifying document assembly?", |
| 1596 | "modifyforms": "allow modifying forms?", | 1600 | "modifyforms": "allow modifying forms?", |
| @@ -1630,7 +1634,7 @@ QPDFJob::json_schema(std::set<std::string>* keys) | @@ -1630,7 +1634,7 @@ QPDFJob::json_schema(std::set<std::string>* keys) | ||
| 1630 | std::string | 1634 | std::string |
| 1631 | QPDFJob::json_out_schema_v1() | 1635 | QPDFJob::json_out_schema_v1() |
| 1632 | { | 1636 | { |
| 1633 | - return json_schema().unparse(); | 1637 | + return json_schema(1).unparse(); |
| 1634 | } | 1638 | } |
| 1635 | 1639 | ||
| 1636 | void | 1640 | void |
| @@ -1717,7 +1721,7 @@ QPDFJob::doJSON(QPDF& pdf, Pipeline* p) | @@ -1717,7 +1721,7 @@ QPDFJob::doJSON(QPDF& pdf, Pipeline* p) | ||
| 1717 | 1721 | ||
| 1718 | if (this->m->test_json_schema) { | 1722 | if (this->m->test_json_schema) { |
| 1719 | // Check against schema | 1723 | // Check against schema |
| 1720 | - JSON schema = json_schema(&m->json_keys); | 1724 | + JSON schema = json_schema(this->m->json_version, &m->json_keys); |
| 1721 | std::list<std::string> errors; | 1725 | std::list<std::string> errors; |
| 1722 | JSON captured = JSON::parse(captured_json); | 1726 | JSON captured = JSON::parse(captured_json); |
| 1723 | if (!captured.checkSchema(schema, errors)) { | 1727 | if (!captured.checkSchema(schema, errors)) { |
qpdf/qtest/qpdf.test
| @@ -4306,8 +4306,8 @@ foreach my $d (@encrypted_files) | @@ -4306,8 +4306,8 @@ foreach my $d (@encrypted_files) | ||
| 4306 | $enc_json .= | 4306 | $enc_json .= |
| 4307 | " \"accessibility\": " . &$jf($accessible) . ",\n" . | 4307 | " \"accessibility\": " . &$jf($accessible) . ",\n" . |
| 4308 | " \"extract\": " . &$jf($extract) . ",\n" . | 4308 | " \"extract\": " . &$jf($extract) . ",\n" . |
| 4309 | - " \"moddifyannotations\": " . &$jf($modifyannot) . ",\n" . | ||
| 4310 | " \"modify\": " . &$jf($modifyall) . ",\n" . | 4309 | " \"modify\": " . &$jf($modifyall) . ",\n" . |
| 4310 | + " \"modifyannotations\": " . &$jf($modifyannot) . ",\n" . | ||
| 4311 | " \"modifyassembly\": " . &$jf($modifyassembly) . ",\n" . | 4311 | " \"modifyassembly\": " . &$jf($modifyassembly) . ",\n" . |
| 4312 | " \"modifyforms\": " . &$jf($modifyform) . ",\n" . | 4312 | " \"modifyforms\": " . &$jf($modifyform) . ",\n" . |
| 4313 | " \"modifyother\": " . &$jf($modifyother) . ",\n" . | 4313 | " \"modifyother\": " . &$jf($modifyother) . ",\n" . |