MIME type matching not working as expected

Helge Blischke h.blischke at acm.org
Wed Dec 15 08:55:41 PST 2010


Christoph Erdle wrote:

> Hi,
> 
> we are trying to implement a differentiation between different types of
> postscript documents. Some of our printers (Ricoh MP C2800) need to be
> accessed with user codes, which can be included on the client side
> directly inside the postscript document which get's sent to CUPS. Those
> documents have to be sent directly to the printers without further
> filtering through foomatic. The routing part work's nicely with manually
> set cupsFilter lines in the PPDs.
> 
> What's not working is the detection of those documents using the MIME
> autotype feature.
> 
> I included the following type definition in /etc/cups/local.types:
> 
> application/postscript-prefiltered     priority(200) + \
>                                 contains(0,4096,"setuserinfo") + \
>                                 (ai eps ps string(0,%!) string(0,<04>%!) \
>                                 contains(0,128,<1B>%-12345X) + \
>                                 (contains(0,4096,"LANGUAGE=POSTSCRIPT") \
>                                  contains(0,4096,"LANGUAGE = Postscript")
>                                  \ contains(0,4096,"LANGUAGE =
>                                  PostScript") \ contains(0,4096,"LANGUAGE
>                                  = POSTSCRIPT") \ (contains(0,4096,<0a>%!)
>                                  + \
>                                   !contains(0,4096,"ENTER LANGUAGE"))))
> 
> Except for the first two lines this is the definition of postscript
> extracted from /usr/share/cups/mime/mime.type. Those files containing the
> string setuserinfo in the postscript header shall be typed as
> application/postscript-prefiltered.
> 
> But this definition does not work as expected. Default postscript docs
> sent to the printer are typed correctly as application/postscript. But
> when sending a document containing the setuserinfo string, those also get
> typed as application/postscript and not as
> application/postscript-prefiltered, as I had expected.
> 
> What am I doing wrong in my attempt to differentiate between the two types
> of postscript docs? Any advice is appreciated.
> 
> The following is the beginning of a PS file send from a client machine
> with set user code (setuserinfo), which is not typed correctly.
> 
> %!PS-Adobe-3.0
> %APL_DSC_Encoding: UTF8
> %APLProducer: (Version 10.6.5 (Build 10H574) Quartz PS Context)
> %%Title: (mime.types - what am I missing - cups.general - Forums - CUPS)
> %%Creator: (Safari: cgpdftops CUPS filter)
> %%CreationDate: (Wednesday, December 15 2010 16:26:30 CET)
> %%For: (Christoph Erdle)
> %%DocumentData: Clean7Bit
> %%LanguageLevel: 3
> %%PageOrder: Ascend
> %RBINumCopies: 1
> %%Pages: (atend)
> %%BoundingBox: (atend)
> %%EndComments
> userdict/dscInfo 5 dict dup begin
> /Title(mime.types - what am I missing - cups.general - Forums - CUPS)def
> /Creator(Safari: cgpdftops CUPS filter)def
> /CreationDate(Wednesday, December 15 2010 16:26:30 CET)def
> /For(Christoph Erdle)def
> /Pages 1 def
> end put
> mark
>   () (731266) (201012151726) {setuserinfo} stopped
> cleartomark
> %%BeginProlog
> %%BeginFile: lw8_errorhandler-2.0
> /currentpacking where
>         { pop /oldpack currentpacking def /setpacking where
>                 {
>                         pop false setpacking
>                 }if
>         }if
> /$brkpage 64 dict def $brkpage begin
> 
> 
> Kind regards,
> Christoph Erdle

First, note that the mime type definitions are lexically sorted by cups at 
startup time, so application/postscript is checked before 
application/postscript-prefiltered.

Second, I strongly recommend to put your userinfo stuff into the prolog 
section or the setup section to avoid this stuff being eliminated by the 
pstops filter.

Helge





More information about the cups mailing list