From f8d1ab946205440ed3c44511ef42e5ad13fb9e5e Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sun, 24 Jul 2022 16:17:03 -0400 Subject: JSON schema -- accept single item in place of array When the schema wants a variable-length array, allow a single item as well as allowing an array. --- include/qpdf/JSON.hh | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include') diff --git a/include/qpdf/JSON.hh b/include/qpdf/JSON.hh index ef1632c2..ebeaaec8 100644 --- a/include/qpdf/JSON.hh +++ b/include/qpdf/JSON.hh @@ -184,6 +184,14 @@ class JSON // * The schema is a nested structure containing dictionaries, // single-element arrays, and strings only. // * Recursively walk the schema. + // * Whenever the schema has an array of length 1 and the object + // does not have an array in the corresponding location, + // validate the object against the array's single element. + // This effectively enables a single element to appear in + // place of an array and be treated as if it were an array of + // one element. This makes it possible to decide later that + // something that used to contain a single element now allows + // an array without invalidating any old data. // * If the current value is a dictionary, this object must have // a dictionary in the same place with the same keys. If flags // contains f_optional, a key in the schema does not have to -- cgit v1.2.3-54-g00ecf