Skip to content

Print-Job requests may include duplicate document-format attributes, causing printer rejection #1457

@zhouliang-gif

Description

@zhouliang-gif

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.

Image

This redundancy leads to job rejection by strict IPP implementations.

The response of Get-Printer-Attributes from the printer is:

Image Image Image

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!

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions