diff --git a/TODO b/TODO index 94aa2dec..b7c4e04b 100644 --- a/TODO +++ b/TODO @@ -61,8 +61,6 @@ General things to remember: * The choices for json_key (job.yml) will be different for v1 and v2. That information is already duplicated in multiple places. -* Remember typo: search for "Typo" In QPDFJob::doJSONEncrypt. - * Test stream with invalid data * Consider using camelCase in multi-word key names to be consistent diff --git a/include/qpdf/QPDFJob.hh b/include/qpdf/QPDFJob.hh index b664ab50..f85c1ec7 100644 --- a/include/qpdf/QPDFJob.hh +++ b/include/qpdf/QPDFJob.hh @@ -445,7 +445,7 @@ class QPDFJob // Helper functions static void usage(std::string const& msg); - static JSON json_schema(std::set* keys = 0); + static JSON json_schema(int json_version, std::set* keys = 0); static void parse_object_id( std::string const& objspec, bool& trailer, int& obj, int& gen); void parseRotationParameter(std::string const&); diff --git a/libqpdf/QPDFJob.cc b/libqpdf/QPDFJob.cc index 5b493101..521377f8 100644 --- a/libqpdf/QPDFJob.cc +++ b/libqpdf/QPDFJob.cc @@ -1374,10 +1374,12 @@ QPDFJob::doJSONEncrypt(Pipeline* p, bool& first, QPDF& pdf) "modifyassembly", JSON::makeBool(pdf.allowModifyAssembly())); j_capabilities.addDictionaryMember( "modifyforms", JSON::makeBool(pdf.allowModifyForm())); - // Typo will be fixed for json v2 /* cSpell:ignore moddifyannotations */ + std::string MODIFY_ANNOTATIONS = + (this->m->json_version == 1 ? "moddifyannotations" + : "modifyannotations"); j_capabilities.addDictionaryMember( - "moddifyannotations", JSON::makeBool(pdf.allowModifyAnnotation())); + MODIFY_ANNOTATIONS, JSON::makeBool(pdf.allowModifyAnnotation())); j_capabilities.addDictionaryMember( "modifyother", JSON::makeBool(pdf.allowModifyOther())); j_capabilities.addDictionaryMember( @@ -1448,7 +1450,7 @@ QPDFJob::doJSONAttachments(Pipeline* p, bool& first, QPDF& pdf) } JSON -QPDFJob::json_schema(std::set* keys) +QPDFJob::json_schema(int json_version, std::set* keys) { // Style: use all lower-case keys with no dashes or underscores. // Choose array or dictionary based on indexing. For example, we @@ -1585,12 +1587,14 @@ QPDFJob::json_schema(std::set* keys) "needappearances": "whether the form fields' appearance streams need to be regenerated" })")); } + std::string MODIFY_ANNOTATIONS = + (json_version == 1 ? "moddifyannotations" : "modifyannotations"); if (all_keys || keys->count("encrypt")) { JSON encrypt = schema.addDictionaryMember("encrypt", JSON::parse(R"({ "capabilities": { "accessibility": "allow extraction for accessibility?", "extract": "allow extraction?", - "moddifyannotations": "allow modifying annotations?", + ")" + MODIFY_ANNOTATIONS + R"(": "allow modifying annotations?", "modify": "allow all modifications?", "modifyassembly": "allow modifying document assembly?", "modifyforms": "allow modifying forms?", @@ -1630,7 +1634,7 @@ QPDFJob::json_schema(std::set* keys) std::string QPDFJob::json_out_schema_v1() { - return json_schema().unparse(); + return json_schema(1).unparse(); } void @@ -1717,7 +1721,7 @@ QPDFJob::doJSON(QPDF& pdf, Pipeline* p) if (this->m->test_json_schema) { // Check against schema - JSON schema = json_schema(&m->json_keys); + JSON schema = json_schema(this->m->json_version, &m->json_keys); std::list errors; JSON captured = JSON::parse(captured_json); if (!captured.checkSchema(schema, errors)) { diff --git a/qpdf/qtest/qpdf.test b/qpdf/qtest/qpdf.test index 369ceaf0..a0cb616a 100644 --- a/qpdf/qtest/qpdf.test +++ b/qpdf/qtest/qpdf.test @@ -4306,8 +4306,8 @@ foreach my $d (@encrypted_files) $enc_json .= " \"accessibility\": " . &$jf($accessible) . ",\n" . " \"extract\": " . &$jf($extract) . ",\n" . - " \"moddifyannotations\": " . &$jf($modifyannot) . ",\n" . " \"modify\": " . &$jf($modifyall) . ",\n" . + " \"modifyannotations\": " . &$jf($modifyannot) . ",\n" . " \"modifyassembly\": " . &$jf($modifyassembly) . ",\n" . " \"modifyforms\": " . &$jf($modifyform) . ",\n" . " \"modifyother\": " . &$jf($modifyother) . ",\n" .