diff -uNr cupsys-1.1.20final+cvs20040330.orig/scheduler/ipp.c cupsys-1.1.20final+cvs20040330/scheduler/ipp.c --- cupsys-1.1.20final+cvs20040330.orig/scheduler/ipp.c 2004-04-01 01:20:47.000000000 +0200 +++ cupsys-1.1.20final+cvs20040330/scheduler/ipp.c 2004-10-15 09:48:42.077382720 +0200 @@ -1220,7 +1220,9 @@ } LogMessage(L_INFO, "Setting %s device-uri to \"%s\" (was \"%s\".)", - printer->name, attr->values[0].string.text, printer->device_uri); + printer->name, + cupsdSanitizeURI(attr->values[0].string.text, line, sizeof(line)), + cupsdSanitizeURI(printer->device_uri, resource, sizeof(resource))); SetString(&printer->device_uri, attr->values[0].string.text); } diff -uNr cupsys-1.1.20final+cvs20040330.orig/scheduler/job.c cupsys-1.1.20final+cvs20040330/scheduler/job.c --- cupsys-1.1.20final+cvs20040330.orig/scheduler/job.c 2004-03-02 01:10:32.000000000 +0100 +++ cupsys-1.1.20final+cvs20040330/scheduler/job.c 2004-10-15 09:49:09.585200896 +0200 @@ -1199,6 +1199,7 @@ classification[1024], /* CLASSIFICATION environment variable */ content_type[1024], /* CONTENT_TYPE environment variable */ device_uri[1024], /* DEVICE_URI environment variable */ + sani_uri[1024], /* Sanitized DEVICE_URI env var */ ppd[1024], /* PPD environment variable */ class_name[255], /* CLASS environment variable */ printer_name[255], /* PRINTER environment variable */ @@ -1695,6 +1696,7 @@ current->filetypes[current->current_file]->super, current->filetypes[current->current_file]->type); snprintf(device_uri, sizeof(device_uri), "DEVICE_URI=%s", printer->device_uri); + cupsdSanitizeURI(printer->device_uri, sani_uri, sizeof(sani_uri)); snprintf(ppd, sizeof(ppd), "PPD=%s/ppd/%s.ppd", ServerRoot, printer->name); snprintf(printer_name, sizeof(printer_name), "PRINTER=%s", printer->name); snprintf(cache, sizeof(cache), "RIP_MAX_CACHE=%s", RIPCache); @@ -1803,7 +1805,10 @@ envp[envc] = NULL; for (i = 0; i < envc; i ++) - LogMessage(L_DEBUG, "StartJob: envp[%d]=\"%s\"", i, envp[i]); + if (strncmp(envp[i], "DEVICE_URI=", 11)) + LogMessage(L_DEBUG, "StartJob: envp[%d]=\"%s\"", i, envp[i]); + else + LogMessage(L_DEBUG, "StartJob: envp[%d]=\"DEVICE_URI=%s\"", i, sani_uri); current->current_file ++; diff -uNr cupsys-1.1.20final+cvs20040330.orig/scheduler/printers.c cupsys-1.1.20final+cvs20040330/scheduler/printers.c --- cupsys-1.1.20final+cvs20040330.orig/scheduler/printers.c 2004-03-02 01:10:33.000000000 +0100 +++ cupsys-1.1.20final+cvs20040330/scheduler/printers.c 2004-10-15 09:48:42.112377400 +0200 @@ -43,6 +43,7 @@ * ValidateDest() - Validate a printer/class destination. * WritePrintcap() - Write a pseudo-printcap file for older * applications that need it... + * cupsdSanitizeURI() - Sanitize a device URI... * write_irix_config() - Update the config files used by the IRIX * desktop tools. * write_irix_state() - Update the status files used by IRIX printing @@ -1131,11 +1132,7 @@ SetPrinterAttrs(printer_t *p) /* I - Printer to setup */ { char uri[HTTP_MAX_URI]; /* URI for printer */ - char method[HTTP_MAX_URI], /* Method portion of URI */ - username[HTTP_MAX_URI], /* Username portion of URI */ - host[HTTP_MAX_URI], /* Host portion of URI */ - resource[HTTP_MAX_URI]; /* Resource portion of URI */ - int port; /* Port portion of URI */ + char resource[HTTP_MAX_URI]; /* Resource portion of URI */ int i; /* Looping var */ char filename[1024]; /* Name of PPD file */ int num_media; /* Number of media options */ @@ -1341,12 +1338,7 @@ * http://..., ipp://..., etc. */ - httpSeparate(p->device_uri, method, username, host, &port, resource); - if (port) - snprintf(uri, sizeof(uri), "%s://%s:%d%s", method, host, port, - resource); - else - snprintf(uri, sizeof(uri), "%s://%s%s", method, host, resource); + cupsdSanitizeURI(p->device_uri, uri, sizeof(uri)); } else { @@ -2152,6 +2144,74 @@ } +/* + * 'cupsdSanitizeURI()' - Sanitize a device URI... + */ + +char * /* O - New device URI */ +cupsdSanitizeURI(const char *uri, /* I - Original device URI */ + char *buffer, /* O - New device URI */ + int buflen) /* I - Size of new device URI buffer */ +{ + char *start, /* Start of data after scheme */ + *slash, /* First slash after scheme:// */ + *ptr; /* Pointer into user@host:port part */ + + + /* + * Range check input... + */ + + if (!uri || !buffer || buflen < 2) + return (NULL); + + /* + * Copy the device URI to the new buffer... + */ + + strlcpy(buffer, uri, buflen); + + /* + * Find the end of the scheme:// part... + */ + + if ((ptr = strchr(buffer, ':')) == NULL) + return (buffer); /* No scheme: part... */ + + for (start = ptr + 1; *start; start ++) + if (*start != '/') + break; + + /* + * Find the next slash (/) in the URI... + */ + + if ((slash = strchr(start, '/')) == NULL) + slash = start + strlen(start); /* No slash, point to the end */ + + /* + * Check for an @ sign before the slash... + */ + + if ((ptr = strchr(start, '@')) != NULL && ptr < slash) + { + /* + * Found an @ sign and it is before the resource part, so we have + * an authentication string. Copy the remaining URI over the + * authentication string... + */ + + cups_strcpy(start, ptr + 1); + } + + /* + * Return the new device URI... + */ + + return (buffer); +} + + #ifdef __sgi /* * 'write_irix_config()' - Update the config files used by the IRIX diff -uNr cupsys-1.1.20final+cvs20040330.orig/scheduler/printers.h cupsys-1.1.20final+cvs20040330/scheduler/printers.h --- cupsys-1.1.20final+cvs20040330.orig/scheduler/printers.h 2004-03-02 01:10:33.000000000 +0100 +++ cupsys-1.1.20final+cvs20040330/scheduler/printers.h 2004-10-15 09:48:42.113377248 +0200 @@ -121,6 +121,9 @@ cups_ptype_t *dtype); extern void WritePrintcap(void); +extern char *cupsdSanitizeURI(const char *uri, char *buffer, + int buflen); + /* * End of "$Id: printers.h,v 1.37 2004/02/25 20:14:53 mike Exp $".