https://bz.apache.org/SpamAssassin/show_bug.cgi?id=7992

--- Comment #20 from Henrik Krohns <apa...@hege.li> ---
- Now uses %{TAGNAME} template format for regex matching
- If any regex rule depends on undefined tag, consider the rule unrun
- Allow tag names to contain underscores
- Add documentation

Committed revision 1901114.

Note that I decided to allow underscores for tag names for naming clarity, it
is enforced as: [A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*(?:\(.*?\))?

"Tag names must consist only of
[A-Z0-9_] characters and must not contain consecutive underscores.  Also the
name must not start or end in an underscore, as that is the template tagging
format."

This also allows for FOO_BAR(args) function style.


Please review this Conf.pm addition about capturing:

==================================================

  CAPTURING TAGS USING REGEX NAMED CAPTURE GROUPS
    SpamAssassin 4.0 supports capturing template tags from regex rules. The
captured tags, along with other standard template tags, can be used in other
rules as a matching string. See TEMPLATE TAGS section for more info on tags.

    Capturing can be done in any body/rawbody/header/uri/full rule that uses a
regex for matching (not eval rules). Standard Perl named capture group format
"(?<NAME>pattern)" must be used, as described in
<https://perldoc.perl.org/perlre#(?%3CNAME%3Epattern)>.

    Example, capturing a tag named "BODY_HELLO_NAME":

     body __HELLO_NAME /\bHello, (?<BODY_HELLO_NAME>\w+)\b/

    The tag can then be used in another rule for matching, using a %{TAGNAME}
template. This would search the captured name in From-header:

     header HELLO_NAME_IN_FROM From =~ /\b%{BODY_HELLO_NAME}\b/i

    If any tag that a rule depends on is not found, then the rule is not run at
all. To prevent a literal %{NAME} string from being parsed as a template, it
can be escaped with a backslash: \%{NAME}.

    Captured tags can also be used in reports and in other plugins like AskDNS,
with the standard "_BODY_HELLO_NAME_" notation.

    Note that at this time there is no automatic dependency tracking for rule
running order. All rules that use named capture groups are automatically set to
priority -10000, so that the tags should always be ready for any normal rules
to use. When rule depends on a tag
    that might be set at later stage by a plugin for example, it's priority
should be set manually to a higher value.

==================================================

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to