From 86ea2012bd413e728c2a3eecf5f2a6de113e3679 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Fri, 22 Dec 2023 14:42:16 -0500 Subject: [PATCH] Allow other than /Yes and /Off in a check box (fixes #1056) --- ChangeLog | 6 ++++++ libqpdf/QPDFFormFieldObjectHelper.cc | 8 ++++---- manual/release-notes.rst | 5 +++++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index b267f4f6..b18283cd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2023-12-22 Jay Berkenbilt + + * When setting a check box value, allow any value other than /Off + to mean checked. This is permitted by the spec. Previously, any + value other than /Yes or /Off was rejected. Fixes #1056. + 2023-12-21 Jay Berkenbilt * Fix to QPDF JSON: a floating point number that appears in diff --git a/libqpdf/QPDFFormFieldObjectHelper.cc b/libqpdf/QPDFFormFieldObjectHelper.cc index 4f7ca0e1..371ed271 100644 --- a/libqpdf/QPDFFormFieldObjectHelper.cc +++ b/libqpdf/QPDFFormFieldObjectHelper.cc @@ -304,10 +304,10 @@ QPDFFormFieldObjectHelper::setV(QPDFObjectHandle value, bool need_appearances) bool okay = false; if (value.isName()) { std::string name = value.getName(); - if ((name == "/Yes") || (name == "/Off")) { - okay = true; - setCheckBoxValue((name == "/Yes")); - } + okay = true; + // Accept any value other than /Off to mean checked. Files have been seen that use + // /1 or other values. + setCheckBoxValue((name != "/Off")); } if (!okay) { this->oh.warnIfPossible("ignoring attempt to set a checkbox field to a value of " diff --git a/manual/release-notes.rst b/manual/release-notes.rst index 2fdd197f..7aa625ab 100644 --- a/manual/release-notes.rst +++ b/manual/release-notes.rst @@ -56,6 +56,11 @@ Planned changes for future 12.x (subject to change): in scientific notation to fixed-point notation since PDF doesn't accept scientific notation. + - When setting a check box value, allow any value other than + ``/Off`` to mean checked. This is permitted by the spec. + Previously, any value other than ``/Yes`` or ``/Off`` was + rejected. + - Build Enhancements: - The qpdf test suite now passes when qpdf is linked with an