procmail
[Top] [All Lists]

regex ending in an optional part

2004-11-26 15:27:27
[Tristan Savatier wrote:]
^TO_hugs <at> foo\.com[^-a-zA-Z0-9.]?

Ruud H.G. van Tol replied:

A regex ending in an optional part, is better without that optional
part.

But if you have the following condition:

 NL = "
" av_B64 = "A-Za-z0-9+/"

 :0 B D
  # [1]
  * $ $NL$NL\/UmFy([$av_B64]+$[^$NL-])+([$av_B64]+)?
  {
    # do something
  }

and you would strip the ending part ([$av_B64]+)? from the regex, thus
having

  # [2]
  * $ $NL$NL\/UmFy([$av_B64]+$[^$NL-])+

the match may then not be complete. You can try if in a mail
containing the following code in the body:

------------1151BAD032138A4
Content-Type: application/octet-stream; name="clam-error.rar"
Content-Transfer-Encoding: XXXX64
Content-Disposition: attachment; filename="clam-error.rar"

UmFyIRoHAM+QcwAADQAAAAAAAADwK3QgkCoAJwEAACACAAAD/TwH7xOvMzEdMwgApIEAAGNs
YW0uZXhlAMAJ2VFQy9XA1zddEJGLNrgtCssaVZJ4BN2R2p7unR0WhRo1TZCVbs/ghsrUGtB8
SUGiUIoJvgC+A7U0qDctLVrR2diKL3s3sCL4A1YGHeZwOc6c55Fn2BzDPsDD9hwMMOU54Czu
jBMMIoE0I4/j6jDnm1YNAC/pEdllX6VShGPl9G2x9OotrqVue97ddAIM3oHHWfztLtK8/GO/
K7598WBwTJaSb92cnotTFNaLuV/b1Cbvi/hcRM9SWXdljaaYFSo6uwIRDEFi4O09wu27Ybbf
zSD6ol2TFOV3aj0C4eSGaZsGwQJL8IcquVMbngHNx5n3JnmpvCZchax0G1aTnEM9eJIRlBLk
Bp4rOwRMsVkLP6j+ZMN5Dy8P/83j0i+5vgiMyYJew+6AxD17AEAHAA==
------------1151BAD032138A4--

The full regex in [1] will catch the entire base 64 encoded RAR file
correctly:

procmail: Matched 
"UmFyIRoHAM+QcwAADQAAAAAAAADwK3QgkCoAJwEAACACAAAD/TwH7xOvMzEdMwgApIEAAGNs
YW0uZXhlAMAJ2VFQy9XA1zddEJGLNrgtCssaVZJ4BN2R2p7unR0WhRo1TZCVbs/ghsrUGtB8
SUGiUIoJvgC+A7U0qDctLVrR2diKL3s3sCL4A1YGHeZwOc6c55Fn2BzDPsDD9hwMMOU54Czu
jBMMIoE0I4/j6jDnm1YNAC/pEdllX6VShGPl9G2x9OotrqVue97ddAIM3oHHWfztLtK8/GO/
K7598WBwTJaSb92cnotTFNaLuV/b1Cbvi/hcRM9SWXdljaaYFSo6uwIRDEFi4O09wu27Ybbf
zSD6ol2TFOV3aj0C4eSGaZsGwQJL8IcquVMbngHNx5n3JnmpvCZchax0G1aTnEM9eJIRlBLk
Bp4rOwRMsVkLP6j+ZMN5Dy8P/83j0i+5vgiMyYJew+6AxD17AEAHAA"

while the truncated regex [2] will miss all but the first characters
of the last line.

best,
rob.

--


____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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