user1774309
user1774309

Reputation: 467

header_checks strange behaviour with regexp

I have this line in header_checks:

/^From:.*finance*./ REJECT

When i test it it rejects the message just fine:

$ postmap -q "From: xxfinancexx" regexp:/etc/postfix/header_checks 
REJECT

But when I remove the letter E from the word finance it also rejects it, even though it shouldn't.

$ postmap -q "From: xxfinancxx" regexp:/etc/postfix/header_checks

Can anyone explain to me why this happens? And how to solve this problem. Thank you.

Upvotes: 1

Views: 1941

Answers (1)

tripleee
tripleee

Reputation: 189937

Your regex is wrong. finance* means financ followed by anything (such as, zero or more occurrences of the letter e. You probably mean

/^From:.*finance/ REJECT

The trailing wildcard (where you had a typo) is redundant; the regex matches even if it doesn't consume the entire input string. But for the record, the regex for "anything" is . (any character) * (zero or more times).

Upvotes: 1

Related Questions