mcst-linux-kernel/patches-2024.06.26/cups-2.3.1/0005-Fixing-job-title-not-i...

49 lines
1.5 KiB
Diff

Link:
Subject: fixing a 'bad job-name value' error when printing documents with titles not in UTF-8 format
Bug: 121691
Tags: common
--- a/cups/dest-job.c 2020-04-09 19:28:01.988596285 +0300
+++ b/cups/dest-job.c 2020-04-09 19:43:45.127636176 +0300
@@ -12,7 +12,8 @@
#include "cups-private.h"
#include "debug-internal.h"
-
+#include <iconv.h>
+#include <langinfo.h>
/*
* 'cupsCancelDestJob()' - Cancel a job on a destination.
@@ -211,9 +212,27 @@
NULL, info->uri);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
NULL, cupsUser());
- if (title)
- ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "job-name", NULL,
- title);
+ if (title) {
+ static iconv_t CONV=(iconv_t)-1;
+ static char strres[PATH_MAX*4];
+
+ if (CONV == (iconv_t)-1)
+ if ((CONV = iconv_open("UTF-8",nl_langinfo(CODESET))) == (iconv_t)-1)
+ title="singlejobnameerr1_alxed";
+ if (CONV != (iconv_t)-1) {
+ size_t l1 = strlen(title);
+ size_t l2 = sizeof(strres);
+ char *inptr = (char*)title;
+ char *outptr = strres;
+ if(iconv(CONV,&inptr,&l1,&outptr,&l2) == (size_t)-1) {
+ title="singlejobnameerr2_alxed";
+ } else {
+ strres[l2] = 0;
+ title = strres;
+ }
+ }
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "job-name", NULL, title);
+ }
cupsEncodeOptions2(request, num_options, options, IPP_TAG_OPERATION);
cupsEncodeOptions2(request, num_options, options, IPP_TAG_JOB);