#425970 procmail: wrong RE behaviour for MATCH token '\/'

Package:
procmail
Source:
procmail
Description:
Versatile e-mail processor
Submitter:
Paolo
Date:
2013-10-15 09:45:04 UTC
Severity:
normal
#425970#5
Date:
2007-05-25 09:45:00 UTC
From:
To:
hi

I've got troubles recently with how the '\/' token gets into play in a
recipe's RE, eg:

* ^subject: *\/.+

that should catch everything to the right *after last ' '* after ':' and
put it into MATCH, ie that's supposed to be like

%  sed -r "s/^subject: *(.+)/\1/i"

but that seems not the case; here's a test:

#--[.prc]---
VERBOSE=yes
:0i
* ^subject: *\/.+
|echo "$MATCH" >&2
#-----------
$ echo -e "To: oo\nFrom: oo\nSubject:  4\n\nx\n."|procmail -m /tmp/.prc
procmail: [23282] Tue May 22 22:25:29 2007
procmail: Assigning "MATCH="
procmail: Matched "  4"
procmail: Match on "^subject: *\/.+"
procmail: Assigning "LASTFOLDER=echo "$MATCH" >&2"
 Subject:  4
   Folder: echo "$MATCH" >&2                                                  34
procmail: Executing "echo "$MATCH" >&2"
  4

ie it's like ' *' after ':' was ignored, it acts like 'formail -x subject:';
the expected result would be instead:

$ echo -e \
  "To: oo\nFrom: oo\nSubject:  4\n\nx\n."|sed -r "s/^subject: *(.+)/\1/i"
To: oo
From: oo
4

x
.

manual warns about weird MATCH results for suboptimal/complex RE, but above
RE isn't suboptimal nor complex, so this looks like an (undocumented) bug.


thanks
--
paolo

#425970#8
Date:
2007-06-28 09:45:13 UTC
From:
To:
Hello.

I received this report from the Debian BTS.
[ Please keep the Cc: lines when replying. Thanks ].

Package: procmail
Version: 3.22-16
Severity: normal

hi

I've got troubles recently with how the '\/' token gets into play in a
recipe's RE, eg:

* ^subject: *\/.+

that should catch everything to the right *after last ' '* after ':' and
put it into MATCH, ie that's supposed to be like

%  sed -r "s/^subject: *(.+)/\1/i"

but that seems not the case; here's a test:

#--[.prc]---
VERBOSE=yes
:0i
* ^subject: *\/.+
|echo "$MATCH" >&2
#-----------
$ echo -e "To: oo\nFrom: oo\nSubject:  4\n\nx\n."|procmail -m /tmp/.prc
procmail: [23282] Tue May 22 22:25:29 2007
procmail: Assigning "MATCH="
procmail: Matched "  4"
procmail: Match on "^subject: *\/.+"
procmail: Assigning "LASTFOLDER=echo "$MATCH" >&2"
 Subject:  4
   Folder: echo "$MATCH" >&2                                                  34
procmail: Executing "echo "$MATCH" >&2"
  4

ie it's like ' *' after ':' was ignored, it acts like 'formail -x subject:';
the expected result would be instead:

$ echo -e \
  "To: oo\nFrom: oo\nSubject:  4\n\nx\n."|sed -r "s/^subject: *(.+)/\1/i"
To: oo
From: oo
4

x
.

manual warns about weird MATCH results for suboptimal/complex RE, but above
RE isn't suboptimal nor complex, so this looks like an (undocumented) bug.


thanks
--
paolo

#425970#15
Date:
2013-10-15 09:32:16 UTC
From:
To:
One might argue that this could be explained better in the manpage though.
The regexp engine inside procmail is tuned for performance, it therefore
does not do fancy things like finding the longest match. Using the
regexp " *\/.+" is therefore unpredictable, since it can match in many
ways.  What you should do, is use a regexp like " *\/[^ ].*" instead.
That will and should do what you want.