]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Fix listing jobs in printers/classes pages in web ui
authorZdenek Dohnal <zdohnal@redhat.com>
Thu, 6 Jun 2024 10:04:20 +0000 (12:04 +0200)
committerZdenek Dohnal <zdohnal@redhat.com>
Thu, 6 Jun 2024 10:04:20 +0000 (12:04 +0200)
CHANGES.md
scheduler/client.c

index c903681f53862e11914ade6df6feb62909679cb3..0be0697f2e507eddc705b4cd9c3c9b9ef0994421 100644 (file)
@@ -12,6 +12,7 @@ Changes in CUPS v2.4.9 (TBA)
   (Issue #751)...
 - Fixed `Host` header regression (Issue #967)
 - Fixed DNS-SD lookups of local services with Avahi (Issue #970)
+- Fixed listing jobs in destinations in web ui.
 
 
 Changes in CUPS v2.4.8 (2024-04-26)
index 2dafd93116475964f8be64e53ee1b536badce417..779404cb8a9328be502cfe1b3e7ddb3e2ad432ef 100644 (file)
@@ -556,6 +556,7 @@ cupsdReadClient(cupsd_client_t *con)        /* I - Client to read from */
 {
   char                 line[32768],    /* Line from client... */
                        locale[64],     /* Locale */
+                       name[128],      /* Class/Printer name */
                        *ptr;           /* Pointer into strings */
   http_status_t                status;         /* Transfer status */
   ipp_state_t          ipp_state;      /* State of IPP transfer */
@@ -1138,16 +1139,29 @@ cupsdReadClient(cupsd_client_t *con)    /* I - Client to read from */
              }
              else if (!strncmp(con->uri, "/classes", 8))
              {
-               if (strlen(con->uri) > 9 && !cupsdFindClass(con->uri + 9))
-               {
-                 if (!cupsdSendError(con, HTTP_STATUS_NOT_FOUND, CUPSD_AUTH_NONE))
+               if (strlen(con->uri) > 9)
+               {
+                 if (con->uri[9] != '?')
                  {
-                   cupsdCloseClient(con);
-                   return;
-                 }
+                   unsigned int i = 0; // Array index
 
-                 break;
-               }
+                   for (char *start = con->uri + 9; *start && *start != '?' && i < sizeof(name);)
+                     name[i++] = *start++;
+
+                   name[i] = '\0';
+
+                   if (!cupsdFindClass(name))
+                   {
+                     if (!cupsdSendError(con, HTTP_STATUS_NOT_FOUND, CUPSD_AUTH_NONE))
+                     {
+                       cupsdCloseClient(con);
+                       return;
+                     }
+
+                     break;
+                   }
+                 }
+               }
 
                cupsdSetStringf(&con->command, "%s/cgi-bin/classes.cgi", ServerBin);
                if (con->uri[8] && con->uri[9])
@@ -1165,16 +1179,29 @@ cupsdReadClient(cupsd_client_t *con)    /* I - Client to read from */
              }
               else if (!strncmp(con->uri, "/printers", 9))
              {
-               if (strlen(con->uri) > 10 && !cupsdFindPrinter(con->uri + 10))
-               {
-                 if (!cupsdSendError(con, HTTP_STATUS_NOT_FOUND, CUPSD_AUTH_NONE))
+               if (strlen(con->uri) > 10)
+               {
+                 if (con->uri[10] != '?')
                  {
-                   cupsdCloseClient(con);
-                   return;
-                 }
+                   unsigned int i = 0; // Array index
 
-                 break;
-               }
+                   for (char *start = con->uri + 10; *start && *start != '?' && i < sizeof(name);)
+                     name[i++] = *start++;
+
+                   name[i] = '\0';
+
+                   if (!cupsdFindPrinter(name))
+                   {
+                     if (!cupsdSendError(con, HTTP_STATUS_NOT_FOUND, CUPSD_AUTH_NONE))
+                     {
+                       cupsdCloseClient(con);
+                       return;
+                     }
+
+                     break;
+                   }
+                 }
+               }
 
                cupsdSetStringf(&con->command, "%s/cgi-bin/printers.cgi", ServerBin);
                 if (con->uri[9] && con->uri[10])