procmail
[Top] [All Lists]

Re: REGEX

2000-12-20 13:08:59
Sergiy Zhuk <serge(_at_)yahoo-inc(_dot_)com> writes:
hi

On Tue, 19 Dec 2000, Philip Guenther wrote:

Is this in the header or the body?  If in the header, then the line

attachment name, which is in the body:

------=_NextPart_000_00CA_01C03F69.C7F96460
Content-Type: image/jpeg;
      name="1.jpg"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
      filename="1.jpg"

--

Here are a few regexps useful for matching the subheaders of the parts
of MIME multipart messages.  The brackets below all contain a space and
a tab.

        # The regexp for matching whitespace in the embedded header field
        # of a multipart message.  We have to handle wrapped lines.
        ws = '[         ]*($[   ]+)*'

        # The regexp for matching 'anything' inside an embedded header
        # field of a multipart message.  That is, it matches anything
        # except the newline (not followed by a whitespace character)
        # that terminates the header field.
        dotstar = '.*($[        ].*)*'

        # A single double-quote.  For use in variable expanded regexps to
        # avoid problems related to how procmail implements the variable
        # expansion
        dq = '"'

        # Any condition that uses any of these variables in a its regexp
        # must have the '$' special before the regexp to tell procmail to
        # do variable expansion on the regexp.


Given those, the condition you want is fairly simple:

        :0 B
        * $ ^Content-[-a-z_]*:${dotstar}name${ws}=${ws}${dq}?filename
        whatever

That matches if there exists a embedded Content-whatever header field
whose value, ignoring legal whitespace, matches the regexp
        .*name="?filename


Philip Guenther
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>