]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
More IPP Everywhere fixes/improvements (Issue #4916)
authorMichael R Sweet <michaelrsweet@gmail.com>
Tue, 8 Nov 2016 16:55:54 +0000 (11:55 -0500)
committerMichael R Sweet <michaelrsweet@gmail.com>
Tue, 8 Nov 2016 16:55:54 +0000 (11:55 -0500)
CHANGES.txt
cups/ppd-cache.c

index 9bec2fe4ad1bd05f0562457c21761a1a34c0727a..6594d47a2411c6e75801eb584acf5b56ddba1ffe 100644 (file)
@@ -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
           (<rdar://problem/28332470>)
+       - 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)
 
index eef8c51c61ca7a7a0e4127ff394e390d3744e45b..070b1f746e560ddd0ff7aeb1a37646e0386e4c2a 100644 (file)
@@ -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: \"<</cupsColorSpace 20/cupsBitsPerColor 16/cupsColorOrder 0/cupsCompression 0>>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);
 }