Skip to content

ppd-cache: fix inverted PWG-to-PPD comparisons for source and type - #112

Merged
tillkamppeter merged 1 commit into
OpenPrinting:masterfrom
ManasBagul23:fix/ppd-cache-inverted-pwg-mapping
Nov 17, 2026
Merged

tillkamppeter merged 1 commit into
OpenPrinting:masterfrom
ManasBagul23:fix/ppd-cache-inverted-pwg-mapping

Conversation

@ManasBagul23

Copy link
Copy Markdown
Contributor

Summary

`ppdPwgInputSlotForSource()` and `ppdPwgMediaTypeForType()` run their whole if/else-if chain on the raw, un-negated result of `_ppd_strcasecmp()`.

The bug

`_ppd_strcasecmp()` follows standard `strcasecmp` semantics: it returns `0` when the strings match. An unnegated `if (_ppd_strcasecmp(media_source, "main"))` is therefore true precisely when `media_source` is not `"main"` -- the opposite of what the if/else-if chain needs. Every other `_ppd_strcasecmp()` call in this file is already negated (`!_ppd_strcasecmp(...)`) or used in a context that actually wants "not equal" (e.g. `cupsCommands != "none"`); these two functions were the only ones using the raw result for an equality branch.

In practice this means both functions pick the PPD InputSlot/MediaType name for essentially the wrong PWG keyword: e.g. media-source `"main"` maps to `"Multipurpose"` instead of `"Cassette"`, media-type `"stationery"` maps to `"Cardstock"` instead of `"Plain"`, and so on down each chain.

Fix

Negate the comparisons, matching the pattern used everywhere else in this file.

Test plan

  • Confirmed both functions are still unnegated on current `master`.
  • Verified `_ppd_strcasecmp()`'s own implementation in `ppd/string.c` returns `0` on a match (standard `strcasecmp` semantics).
  • Checked every other `_ppd_strcasecmp()` call site in `ppd-cache.c`: the two outside these functions are correctly used for a "not equal" condition, confirming the bug is isolated to these two functions.

ppdPwgInputSlotForSource() and ppdPwgMediaTypeForType() ran their
whole if/else-if chain on the raw, un-negated result of
_ppd_strcasecmp(), which returns 0 for a match (standard strcasecmp
semantics) - the opposite of what a truthy if-condition needs. Every
other comparison in this file already negates it
(!_ppd_strcasecmp(...)); these two functions were the only ones that
didn't, so they picked the PPD InputSlot/MediaType name for the wrong
PWG keyword in almost every case, e.g. media-source "main" got mapped
to "Multipurpose" instead of "Cassette". Negate the comparisons like
everywhere else.
Copilot AI balanced review requested due to automatic review settings November 17, 2026 19:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@tillkamppeter
tillkamppeter merged commit 94ae474 into OpenPrinting:master Nov 17, 2026
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants