From: Michael R Sweet Date: Mon, 4 May 2026 20:18:44 +0000 (-0400) Subject: Support standard PPD, PWG, and legacy names for media/PageSize regardless of the... X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=226f509;p=thirdparty%2Fcups.git Support standard PPD, PWG, and legacy names for media/PageSize regardless of the PPD file (Issue #1375) --- diff --git a/CHANGES.md b/CHANGES.md index 14c10b2fdb..ce21046fe4 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -167,6 +167,8 @@ v2.5b1 - YYYY-MM-DD - Fixed unreachable block in IPP backend (Issue #1351) - Fixed memory leak in `_cupsConvertOptions()` (Issue #1354) - Fixed missing write check in `cupsFileOpen/Fd` (Issue #1360) +- Fixed mapping of standard PPD/PWG/legacy media size names to the local PPD + size name (Issue #1375) - Fixed error recovery when scanning for PPDs in `cups-driverd` (Issue #1416) - Fixed allowed values for directive `FilterNice` - Fixed an allocation bug in the `rastertoepson` filter (Issue #1537) diff --git a/cups/ppd-mark.c b/cups/ppd-mark.c index 3e1a5968bf..ac7cf8465f 100644 --- a/cups/ppd-mark.c +++ b/cups/ppd-mark.c @@ -1,7 +1,7 @@ /* * Option marking routines for CUPS. * - * Copyright © 2020-2025 by OpenPrinting. + * Copyright © 2020-2026 by OpenPrinting. * Copyright © 2007-2019 by Apple Inc. * Copyright © 1997-2007 by Easy Software Products, all rights reserved. * @@ -793,6 +793,9 @@ ppd_mark_option(ppd_file_t *ppd, /* I - PPD file */ cupsArraySave(ppd->options); + if (!_cups_strcasecmp(option, "media") || !_cups_strcasecmp(option, "media-col")) + option = "PageSize"; + o = ppdFindOption(ppd, option); cupsArrayRestore(ppd->options); @@ -811,7 +814,7 @@ ppd_mark_option(ppd_file_t *ppd, /* I - PPD file */ if ((c = ppdFindChoice(o, "Custom")) == NULL) return; - if (!_cups_strcasecmp(option, "PageSize")) + if (!_cups_strcasecmp(option, "PageRegion") || !_cups_strcasecmp(option, "PageSize")) { /* * Handle custom page sizes... @@ -889,6 +892,34 @@ ppd_mark_option(ppd_file_t *ppd, /* I - PPD file */ choice = "Custom"; } + else if (!_cups_strcasecmp(option, "PageRegion") || !_cups_strcasecmp(option, "PageSize")) + { + /* + * Handle page sizes as PPD, legacy, or PWG names... + */ + + ppd_size_t *ppdsize; /* PPD size */ + + if ((ppdsize = ppdPageSize(ppd, choice)) == NULL) + { + /* + * Not a PPD size name, look it up... + */ + + const char *pagesize; /* PPD PageSize choice */ + + if ((pagesize = _ppdCacheGetPageSize(ppd->cache, /*job*/NULL, choice, /*exact*/NULL)) != NULL) + ppdsize = ppdPageSize(ppd, pagesize); + } + + if (!ppdsize) + return; + + choice = ppdsize->name; + + if ((c = ppdFindChoice(o, choice)) == NULL) + return; + } else if (choice[0] == '{') { /*