-
Notifications
You must be signed in to change notification settings - Fork 263
Description
Description:
When submitting a Print-Job request via CUPS, the document-format attribute can be added twice, which violates the IPP specification (RFC 8011) that defines document-format as a single-value operation attribute. This duplication can cause the IPP printer which I was testing to reject the job.
Specifically, in backend/ipp.c, the new_request() function adds document-format if format is provided and the operation is not Create-Job:
if (format && op != IPP_OP_CREATE_JOB)
{
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_MIMETYPE, "document-format", NULL, format);
fprintf(stderr, "DEBUG: document-format=\"%s\"\n", format);
}Later, cupsEncodeOptions2() is called (around line 2991), which adds document-format again when processing job options for Print-Job:
if (group_tag == IPP_TAG_OPERATION && (op == IPP_OP_PRINT_JOB || ...))
{
if ((val = (char *)cupsGetOption("document-format", num_options, options)) != NULL)
ippAddString(ipp, IPP_TAG_OPERATION, IPP_TAG_MIMETYPE, "document-format", NULL, val);
else if (cupsGetOption("raw", ...))
...
else
ippAddString(..., "application/octet-stream");
}As a result, the final IPP request may contain two document-format attributes.
This redundancy leads to job rejection by strict IPP implementations.
The response of Get-Printer-Attributes from the printer is:
Do you have any recommendations on the proper way to handle this? Should new_request() avoid setting document-format when it’s already in the options? Or should cupsEncodeOptions2() check for an existing attribute before adding one? Thanks!