From: mike Date: Wed, 3 Apr 2013 16:16:46 +0000 (+0000) Subject: The cupsfilter program did not set the FINAL_CONTENT_TYPE environment variable X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2340932ef28e7e153cc6f53e122cd7e5ba03cb46;p=thirdparty%2Fcups.git The cupsfilter program did not set the FINAL_CONTENT_TYPE environment variable for filters. git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@10937 7a7537e8-13f0-0310-91df-b6672ffda945 --- diff --git a/CHANGES.txt b/CHANGES.txt index fe7c686ef1..5d1b8c38f8 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,8 +1,10 @@ -CHANGES.txt - 1.7b1 - 2013-03-11 +CHANGES.txt - 1.7b1 - 2013-04-03 -------------------------------- CHANGES IN CUPS V1.7b1 + - The cupsfilter program did not set the FINAL_CONTENT_TYPE + environment variable for filters. - Added a new "-x" option to the cancel command (STR #4103) - Made the PWG media handling APIs public (STR #4267) - Implemented ready media support for the cupsGetDestMediaXxx APIs diff --git a/scheduler/cupsfilter.c b/scheduler/cupsfilter.c index 7851967b1d..177766e534 100644 --- a/scheduler/cupsfilter.c +++ b/scheduler/cupsfilter.c @@ -917,7 +917,7 @@ exec_filters(mime_type_t *srctype, /* I - Source type */ { int i; /* Looping var */ const char *argv[8], /* Command-line arguments */ - *envp[16], /* Environment variables */ + *envp[17], /* Environment variables */ *temp; /* Temporary string */ char *optstr, /* Filter options */ content_type[1024], /* CONTENT_TYPE */ @@ -925,6 +925,8 @@ exec_filters(mime_type_t *srctype, /* I - Source type */ cups_fontpath[1024], /* CUPS_FONTPATH */ cups_serverbin[1024], /* CUPS_SERVERBIN */ cups_serverroot[1024], /* CUPS_SERVERROOT */ + final_content_type[1024] = "", + /* FINAL_CONTENT_TYPE */ lang[1024], /* LANG */ path[1024], /* PATH */ ppd[1024], /* PPD */ @@ -947,6 +949,39 @@ exec_filters(mime_type_t *srctype, /* I - Source type */ cups_dest_t *dest; /* Destination information */ + /* + * Figure out the final content type... + */ + + for (filter = (mime_filter_t *)cupsArrayLast(filters); + filter && filter->dst; + filter = (mime_filter_t *)cupsArrayPrev(filters)) + if (strcmp(filter->dst->super, "printer")) + break; + + if (filter && filter->dst) + { + const char *ptr; /* Pointer in type name */ + + if ((ptr = strchr(filter->dst->type, '/')) != NULL) + snprintf(final_content_type, sizeof(final_content_type), + "FINAL_CONTENT_TYPE=%s", ptr + 1); + else + snprintf(final_content_type, sizeof(final_content_type), + "FINAL_CONTENT_TYPE=%s/%s", filter->dst->super, + filter->dst->type); + } + + /* + * Remove NULL ("-") filters... + */ + + for (filter = (mime_filter_t *)cupsArrayFirst(filters); + filter; + filter = (mime_filter_t *)cupsArrayNext(filters)) + if (!strcmp(filter->filter, "-")) + cupsArrayRemove(filters, filter); + /* * Setup the filter environment and command-line... */ @@ -1041,7 +1076,13 @@ exec_filters(mime_type_t *srctype, /* I - Source type */ envp[12] = rip_max_cache; envp[13] = userenv; envp[14] = "CHARSET=utf-8"; - envp[15] = NULL; + if (final_content_type[0]) + { + envp[15] = final_content_type; + envp[16] = NULL; + } + else + envp[15] = NULL; for (i = 0; argv[i]; i ++) fprintf(stderr, "DEBUG: argv[%d]=\"%s\"\n", i, argv[i]);