#653624 procmail: \< pattern match expression broken

Package:
procmail
Source:
procmail
Description:
Versatile e-mail processor
Submitter:
Bob Proulx
Date:
2013-10-15 19:15:32 UTC
Severity:
normal
#653624#5
Date:
2011-12-29 21:02:44 UTC
From:
To:
Tong on the debian-user mailing list reported that \<...\> was not
working.  I investigated it somewhat, can confirm the broken behavior,
and after looking at it a little I think it is a bug in \< expansion.

The procmailrc man page says:

       \< or \>  Match the character before or after a word.  They are  merely
                 a shorthand for `[^a-zA-Z0-9_]', but can also match newlines.
                 Since they match actual characters, they are only suitable to
                 delimit words, not to delimit inter-word space.

The \< appears broken.  However quite interestingly \\< appears to
work okay.  I wondered if there was a problem with backslash handling
and tried a few combinations of it and found that \\< seems to behave
as \< should be behaving.  For example the following test case and
looking at the verbose output to see what is matched and what is not
matched.

  VERBOSE=on

  :0 HB
  * 1^0 testword
  * 1^0 \<testword\>
  * 1^0 \<testword
  * 1^0 testword\>
  * 1^0 \\<testword
  * 1^0 \\<testword\>
  testwordfolder

It appears that \\< works where \< should work.  I didn't look at the
code to see how this only affected the before word case and not the
after word case too.  There should be a clue there.

Thank you for maintaining procmail!

Bob

#653624#12
Date:
2013-10-15 19:03:04 UTC
From:
To:
If there is a < at the start of a regexp, it needs to be escaped. If you
want \< at the beginning of a regexp, you need to double escape the \ at
the beginning.
This is due to the fact that a < character at the beginning of the
regexp has special meaning.

Any suggestions as to how/where to better document this, are welcome.

#653624#15
Date:
2013-10-15 19:03:04 UTC
From:
To:
If there is a < at the start of a regexp, it needs to be escaped. If you
want \< at the beginning of a regexp, you need to double escape the \ at
the beginning.
This is due to the fact that a < character at the beginning of the
regexp has special meaning.

Any suggestions as to how/where to better document this, are welcome.