From 4400ce84eeb204cdcb35950dd8fde094fc249051 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Thu, 21 Dec 2023 17:14:28 -0500 Subject: Add "n:/pdf-name" to qpdf JSON for binary names (fixes #1072) --- libqpdf/QPDF_json.cc | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'libqpdf/QPDF_json.cc') diff --git a/libqpdf/QPDF_json.cc b/libqpdf/QPDF_json.cc index f8fd689a..864e1a56 100644 --- a/libqpdf/QPDF_json.cc +++ b/libqpdf/QPDF_json.cc @@ -144,6 +144,12 @@ is_name(std::string const& v) return ((v.length() > 1) && (v.at(0) == '/')); } +static bool +is_pdf_name(std::string const& v) +{ + return ((v.length() > 3) && (v.substr(0, 3) == "n:/")); +} + bool QPDF::test_json_validators() { @@ -740,6 +746,8 @@ QPDF::JSONReactor::makeObject(JSON const& value) result = QPDFObjectHandle::newString(QUtil::hex_decode(str)); } else if (is_name(str_v)) { result = QPDFObjectHandle::newName(str_v); + } else if (is_pdf_name(str_v)) { + result = QPDFObjectHandle::parse(str_v.substr(2)); } else { QTC::TC("qpdf", "QPDF_json unrecognized string value"); error(value.getStart(), "unrecognized string value"); -- cgit v1.2.3-54-g00ecf