Skip to content

Fix JSON separator and value validation - #1789

Merged
michaelrsweet merged 2 commits into
OpenPrinting:masterfrom
Shubham-Padkonde:fix/json-separator-validation
Oct 26, 2026
Merged

michaelrsweet merged 2 commits into
OpenPrinting:masterfrom
Shubham-Padkonde:fix/json-separator-validation

Conversation

@Shubham-Padkonde

Copy link
Copy Markdown
Contributor

cupsJSONImportString() accepts inputs such as {"a":}, {"a":[1 2]}, and {} trailing text. Require commas between members/elements, a value after a colon, and only whitespace after the root object. This prevents incomplete key/value pairs from being returned as successfully parsed objects.

Fixes #1788.

The regression table contains 21 valid and invalid examples, including nested/empty containers and surrounding whitespace. Eleven malformed examples were accepted before the fix; all 21 now behave as expected.

Validation on Linux/WSL with the existing configured build:

  • Rebuilt cups/testjson and the static CUPS library.
  • Ran make -C cups test: 656 passing checks across the array, clock, file, form, HTTP, IPP, internationalization, JSON, JWT, language, option, PPD, PWG, and raster tests.
  • One existing external check fails: retrieving Google's OpenID configuration reports Credentials do not validate against CA certificates. It failed before and after this change. Certificate validation was not bypassed.
  • git diff --check passed.

The current test helper does not propagate testEndMessage(false, ...) to the program's exit status, so validation above is based on the individual results, not just the command exit code. The new regression table uses testEnd, which correctly returns a failing status before the fix. The helper issue is being handled separately.

Signed-off-by: Shubham Padkonde <shubhampadkonde12@gmail.com>
@michaelrsweet michaelrsweet self-assigned this Oct 26, 2026
@michaelrsweet michaelrsweet added the bug Something isn't working label Oct 26, 2026
@michaelrsweet michaelrsweet added this to the v2.5 milestone Oct 26, 2026

@michaelrsweet michaelrsweet left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the addition of the syntax checks to the unit test file.

I think there are some coding style things here I'll need to tweak but I can do that post-merge.

@michaelrsweet
michaelrsweet merged commit add41ee into OpenPrinting:master Oct 26, 2026
6 checks passed
michaelrsweet added a commit that referenced this pull request Oct 26, 2026
- Coding style/indentation
- Update testjson output for syntax checks
- Update test-internal.h to escape strings in output
@michaelrsweet

Copy link
Copy Markdown
Member

[master 771cd9b] Cleanup (Issue #1789):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JSON import accepts missing separators and values

2 participants