Skip to content

Commit 2536dc6

Browse files
committed
Fix listing jobs in printers/classes pages in web ui
1 parent 62c01bb commit 2536dc6

2 files changed

Lines changed: 44 additions & 16 deletions

File tree

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Changes in CUPS v2.4.9 (TBA)
1212
(Issue #751)...
1313
- Fixed `Host` header regression (Issue #967)
1414
- Fixed DNS-SD lookups of local services with Avahi (Issue #970)
15+
- Fixed listing jobs in destinations in web ui.
1516

1617

1718
Changes in CUPS v2.4.8 (2024-04-26)

scheduler/client.c

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,7 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */
556556
{
557557
char line[32768], /* Line from client... */
558558
locale[64], /* Locale */
559+
name[128], /* Class/Printer name */
559560
*ptr; /* Pointer into strings */
560561
http_status_t status; /* Transfer status */
561562
ipp_state_t ipp_state; /* State of IPP transfer */
@@ -1138,16 +1139,29 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */
11381139
}
11391140
else if (!strncmp(con->uri, "/classes", 8))
11401141
{
1141-
if (strlen(con->uri) > 9 && !cupsdFindClass(con->uri + 9))
1142-
{
1143-
if (!cupsdSendError(con, HTTP_STATUS_NOT_FOUND, CUPSD_AUTH_NONE))
1142+
if (strlen(con->uri) > 9)
1143+
{
1144+
if (con->uri[9] != '?')
11441145
{
1145-
cupsdCloseClient(con);
1146-
return;
1147-
}
1146+
unsigned int i = 0; // Array index
11481147

1149-
break;
1150-
}
1148+
for (char *start = con->uri + 9; *start && *start != '?' && i < sizeof(name);)
1149+
name[i++] = *start++;
1150+
1151+
name[i] = '\0';
1152+
1153+
if (!cupsdFindClass(name))
1154+
{
1155+
if (!cupsdSendError(con, HTTP_STATUS_NOT_FOUND, CUPSD_AUTH_NONE))
1156+
{
1157+
cupsdCloseClient(con);
1158+
return;
1159+
}
1160+
1161+
break;
1162+
}
1163+
}
1164+
}
11511165

11521166
cupsdSetStringf(&con->command, "%s/cgi-bin/classes.cgi", ServerBin);
11531167
if (con->uri[8] && con->uri[9])
@@ -1165,16 +1179,29 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */
11651179
}
11661180
else if (!strncmp(con->uri, "/printers", 9))
11671181
{
1168-
if (strlen(con->uri) > 10 && !cupsdFindPrinter(con->uri + 10))
1169-
{
1170-
if (!cupsdSendError(con, HTTP_STATUS_NOT_FOUND, CUPSD_AUTH_NONE))
1182+
if (strlen(con->uri) > 10)
1183+
{
1184+
if (con->uri[10] != '?')
11711185
{
1172-
cupsdCloseClient(con);
1173-
return;
1174-
}
1186+
unsigned int i = 0; // Array index
11751187

1176-
break;
1177-
}
1188+
for (char *start = con->uri + 10; *start && *start != '?' && i < sizeof(name);)
1189+
name[i++] = *start++;
1190+
1191+
name[i] = '\0';
1192+
1193+
if (!cupsdFindPrinter(name))
1194+
{
1195+
if (!cupsdSendError(con, HTTP_STATUS_NOT_FOUND, CUPSD_AUTH_NONE))
1196+
{
1197+
cupsdCloseClient(con);
1198+
return;
1199+
}
1200+
1201+
break;
1202+
}
1203+
}
1204+
}
11781205

11791206
cupsdSetStringf(&con->command, "%s/cgi-bin/printers.cgi", ServerBin);
11801207
if (con->uri[9] && con->uri[10])

0 commit comments

Comments
 (0)