From: Michael R Sweet Date: Tue, 8 Nov 2016 16:55:54 +0000 (-0500) Subject: More IPP Everywhere fixes/improvements (Issue #4916) X-Git-Tag: v2.2.2~45 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d4259b45a4465553eccfefa75f773cd8ba2b54ce;p=thirdparty%2Fcups.git More IPP Everywhere fixes/improvements (Issue #4916) --- diff --git a/CHANGES.txt b/CHANGES.txt index 9bec2fe4ad..6594d47a24 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,11 +1,11 @@ -CHANGES.txt - 2.2.2 - 2016-11-07 +CHANGES.txt - 2.2.2 - 2016-11-08 -------------------------------- CHANGES IN CUPS V2.2.2 - Fixed some issues with the Zebra ZPL printer driver (Issue #4898) - Fixed some issues with IPP Everywhere printer support (Issue #4893, - Issue #4909) + Issue #4909, Issue #4916) - The cups-lpd program did not catch all legacy usage of ISO-8859-1 (Issue #4899) - Fixed builds on systems without a working poll() implementation @@ -13,6 +13,8 @@ CHANGES IN CUPS V2.2.2 - Added a USB quirk rule for the Kyocera Ecosys P6026cdn (Issue #4900) - The scheduler no longer creates log files on startup () + - The ippContainsString function now uses case-insensitive comparisons + for mimeMediaType, name, and text values in conformance with RFC 2911. - Updated documentation (PR #4896) - Updated localizations (PR #4894, PR #4895, PR #4904, PR #4908) diff --git a/cups/ppd-cache.c b/cups/ppd-cache.c index eef8c51c61..070b1f746e 100644 --- a/cups/ppd-cache.c +++ b/cups/ppd-cache.c @@ -2925,7 +2925,7 @@ _ppdCacheWriteFile( * of an IPP printer. */ -char * /* O - PPD filename or NULL on error */ +char * /* O - PPD filename or @code NULL@ on error */ _ppdCreateFromIPP(char *buffer, /* I - Filename buffer */ size_t bufsize, /* I - Size of filename buffer */ ipp_t *response) /* I - Get-Printer-Attributes response */ @@ -2944,7 +2944,10 @@ _ppdCreateFromIPP(char *buffer, /* I - Filename buffer */ bottom, /* Largest bottom margin */ left, /* Largest left margin */ right, /* Largest right margin */ - top; /* Largest top margin */ + top, /* Largest top margin */ + is_apple = 0, /* Does the printer support Apple raster? */ + is_pdf = 0, /* Does the printer support PDF? */ + is_pwg = 0; /* Does the printer support PWG Raster? */ pwg_media_t *pwg; /* PWG media size */ int xres, yres; /* Resolution values */ cups_lang_t *lang = cupsLangDefault(); @@ -3089,18 +3092,31 @@ _ppdCreateFromIPP(char *buffer, /* I - Filename buffer */ if ((attr = ippFindAttribute(response, "document-format-supported", IPP_TAG_MIMETYPE)) != NULL) { + is_apple = ippContainsString(attr, "image/urf"); + is_pdf = ippContainsString(attr, "application/pdf"); + is_pwg = ippContainsString(attr, "image/pwg-raster"); + for (i = 0, count = ippGetCount(attr); i < count; i ++) { const char *format = ippGetString(attr, i, NULL); /* PDL */ + /* + * Write cupsFilter2 lines for supported formats, except for PostScript + * (which has compatibility problems over IPP with some vendors), text, + * TIFF, and vendor MIME media types... + */ + if (!_cups_strcasecmp(format, "application/pdf")) cupsFilePuts(fp, "*cupsFilter2: \"application/vnd.cups-pdf application/pdf 10 -\"\n"); - else if (_cups_strcasecmp(format, "application/octet-stream") && _cups_strcasecmp(format, "application/postscript") && _cups_strncasecmp(format, "application/vnd.hp-pcl", 23) && _cups_strcasecmp(format, "image/tiff") && _cups_strcasecmp(format, "text/plain")) + else if (_cups_strcasecmp(format, "application/octet-stream") && _cups_strcasecmp(format, "application/postscript") && _cups_strncasecmp(format, "application/vnd.", 16) && _cups_strncasecmp(format, "image/vnd.", 10) && _cups_strcasecmp(format, "image/tiff") && _cups_strncasecmp(format, "text/", 5)) cupsFilePrintf(fp, "*cupsFilter2: \"%s %s 10 -\"\n", format, format); } } + if (!is_apple && !is_pdf && !is_pwg) + goto bad_ppd; + /* * PageSize/PageRegion/ImageableArea/PaperDimension */ @@ -3246,6 +3262,8 @@ _ppdCreateFromIPP(char *buffer, /* I - Filename buffer */ } } } + else + goto bad_ppd; /* * InputSlot... @@ -3539,7 +3557,8 @@ _ppdCreateFromIPP(char *buffer, /* I - Filename buffer */ cupsFilePrintf(fp, "*ColorModel AdobeRGB/%s: \"<>setpagedevice\"\n", _cupsLangString(lang, _("Deep Color"))); - default_color = "AdobeRGB"; + if (!default_color) + default_color = "AdobeRGB"; } } @@ -3750,7 +3769,7 @@ _ppdCreateFromIPP(char *buffer, /* I - Filename buffer */ * Invalid "urf-supported" value... */ - cupsFilePuts(fp, "*DefaultResolution: 300dpi\n"); + goto bad_ppd; } else { @@ -3771,6 +3790,8 @@ _ppdCreateFromIPP(char *buffer, /* I - Filename buffer */ cupsFilePuts(fp, "*CloseUI: *cupsPrintQuality\n"); } } + else if (is_apple || is_pwg) + goto bad_ppd; else if ((attr = ippFindAttribute(response, "printer-resolution-default", IPP_TAG_RESOLUTION)) != NULL) { pwg_ppdize_resolution(attr, 0, &xres, &yres, ppdname, sizeof(ppdname)); @@ -3786,6 +3807,18 @@ _ppdCreateFromIPP(char *buffer, /* I - Filename buffer */ cupsFileClose(fp); return (buffer); + + /* + * If we get here then there was a problem creating the PPD... + */ + + bad_ppd: + + cupsFileClose(fp); + unlink(buffer); + *buffer = '\0'; + + return (NULL); }