procmail
[Top] [All Lists]

Re: Et TO, procmail ?

1997-09-16 07:52:38
vikas(_at_)insight(_dot_)att(_dot_)com wrote:
        If the regular expression contains `^TO_' it will be substi-
          tuted by `(^((Original-)?(Resent-)?(To|Cc|Bcc)|(X-Envelope
          |Apparently(-Resent)?)-To):(.*[^-a-zA-Z0-9_.])?)', which
          should catch all destination specifications containing a
          specific address.

Let's rewrite that in perl /x format.

/                               # [begin regexp]
 (                              # [Block (A)]
  ^                             # Anchor to start of line 
   (                            # [Block (B)]
     (Original-)?               # Optionally proceed (C) with "Original-"
      (Resent-)?                # Optionally proceed (C) with "Resent-"
              (                 # [Block (C)]
               To               # "To"
              |Cc               # or "Cc"
              |Bcc              # or "Bcc" {very rare in practice}
              )                 # [end (C)]
     | (                        # [Block (D)]
        X-Envelope              # Proceed line 17 with "X-Envelope"
       |Apparently              # or "Apparently"
           (-Resent)?           #    with optional "-Resent" appended
       )                        # [end (D)]
          -To                   # "-To" [line 14]
    )                           # [end (B)]
       :                        # ":"
       (                        # [Block (E)]
        .*                      # any text
          [^-a-zA-Z0-9_.]       # any single char other than letters, numbers,
                                # hyphen (-), underscore (_), or period (.)
       )                        # [end (E)]
        ?                       # Block (E) is optional
 )                              # [end (A)]
/x                              # [end regexp]

Is that clearer?

          If the regular expression contains `^TO' it will be  substi-
          tuted by `(^((Original-)?(Resent-)?(To|Cc|Bcc)|(X-Envelope
          |Apparently(-Resent)?)-To):(.*[^a-zA-Z])?)', which should
          catch all destination specifications containing a specific
          word.

This is the same except that block (E) ends with anything other than a
letter.

1. How does it handle the real-name part of the TO address? This can
contain pretty much any garbage according to RFC822 as long as the address
is enclosed between <...> ?

Block (E) is there to slurp up that part. The <encapsulation> is not
needed, and a case such as:

        From: "jester(_at_)fun(_dot_)house" <fool(_at_)aol(_dot_)com>

Will confuse a test for "^TO_jester@". Yes, I have seen people do
that stuff, apparently not even maliciously.

2. How does it handle To:/Cc: lines split over multiple lines?

This is procmail magic, suffice to know it does handle them.

3. What is the essential difference (again, in plain English, please!)
between TO and TO_ ?

The definition of the word boundary in block (E).

4. What in the world is (.*[^-a-zA-Z0-9_.])?   ?

See above.

Thanks a lot,

All things considered, these are fairly simple regular expressions.

Elijah
------
I /dev/null dupes, no need to CC list posts.  It is not my responsibility to
prove to you my mail is not spam, if mail to you bounces it will not be resent.
------
#!/usr/bin/perl -w
$_="<j!y~f^v* >h(_dot_)g=c+m\(_at_)q[p;r} ?x/t|d:l# 
)e\\p.d-s]p{c<,\n";$j=0;while(
s"[^\w\s,](.*)"($u=$1,$u=~s;(\w);(($s=ord($1)-97),chr((($s+$j++)%26)+97
));gex,$u)"ex){}exit !print;#18/5/97:etb

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