Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix duplicate PPD->IPP media-type name mappings #688

Merged

Conversation

Plombo
Copy link
Contributor

@Plombo Plombo commented May 12, 2023

If more than one MediaType in a PPD matched the pattern for a registered PWG media-type name, they would all be mapped to that name, making it impossible for a client using CUPS' IPP interface to distinguish between them or specify a particular one.

This comes up with Epson-provided PPDs like this one, which frequently hit this case by combining print quality with media type like so:

*MediaType PLAIN_HIGH/Plain paper-High: "
*MediaType PLAIN_NORMAL/Plain paper-Standard: "

Solve this problem by not assigning the standard PWG name to either one when such duplication occurs.

cups/ppd-cache.c Fixed Show fixed Hide fixed
cups/ppd-cache.c Fixed Show fixed Hide fixed
@Plombo Plombo force-pushed the media-type-no-duplicate-names branch from 35442c5 to d4f91f4 Compare May 17, 2023 16:04
Copy link
Member

@michaelrsweet michaelrsweet left a comment

Choose a reason for hiding this comment

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

Generally good, some coding style fixes needed plus one error when adding up the "auto" values.

cups/ppd-cache.c Outdated Show resolved Hide resolved
cups/ppd-cache.c Outdated Show resolved Hide resolved
cups/ppd-cache.c Show resolved Hide resolved
cups/ppd-cache.c Outdated Show resolved Hide resolved
cups/ppd-cache.c Outdated Show resolved Hide resolved
cups/ppd-cache.c Outdated Show resolved Hide resolved
cups/ppd-cache.c Outdated Show resolved Hide resolved
@zdohnal
Copy link
Member

zdohnal commented May 22, 2023

@michaelrsweet here I wasn't sure whether this is something we should tackle, because it seems like PPD problem to me and we could report a warning when reading the file plus use the first/the last value of the same translation string.

@michaelrsweet
Copy link
Member

@zdohnal It isn't unusual for a PPD file to contain some odd media type names, and the proposed change is reasonable to preserve the ability to select any PPD media type via IPP.

@Plombo Plombo force-pushed the media-type-no-duplicate-names branch from d4f91f4 to 9b0c59e Compare May 22, 2023 17:16
@Plombo
Copy link
Contributor Author

Plombo commented May 22, 2023

Thanks for the review! I've implemented all of your recommended changes except for the one about the evaluation order of the chained assignment, which I replied to.

@Plombo Plombo requested a review from michaelrsweet May 22, 2023 17:22
If more than one MediaType in a PPD matched the pattern for a registered
PWG media-type name, they would all be mapped to that name, making it
impossible for a client using CUPS' IPP interface to distinguish between
them or specify a particular one.

This comes up with Epson-provided PPDs, which frequently hit this case
by combining print quality with media type like so:
*MediaType PLAIN_HIGH/Plain paper-High: "
*MediaType PLAIN_NORMAL/Plain paper-Standard: "

Solve this problem by not assigning the standard PWG name to either one
when such duplication occurs.
@Plombo Plombo force-pushed the media-type-no-duplicate-names branch from 9b0c59e to 55f5b24 Compare May 24, 2023 17:23
@Plombo
Copy link
Contributor Author

Plombo commented May 24, 2023

Implemented the last suggested change, using a temporary variable for the sum of the "auto" values.

@michaelrsweet michaelrsweet merged commit 857bc2e into OpenPrinting:master May 24, 2023
5 of 6 checks passed
@michaelrsweet michaelrsweet added bug Something isn't working priority-low labels May 24, 2023
@michaelrsweet michaelrsweet added this to the v2.4.3 milestone May 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority-low
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants