From: Stoiko Ivanov <s.ivanov@proxmox.com>
To: pmg-devel@lists.proxmox.com
Subject: [pmg-devel] [PATCH pmg-api v2] rulesystem: matchfield: match all headers not only the first
Date: Tue, 17 May 2022 12:19:50 +0200 [thread overview]
Message-ID: <20220517101950.24110-1-s.ivanov@proxmox.com> (raw)
currently the match field uses $entity->head->get in scalar context,
which only returns the first matching header (see [0])
switch over to using get_all in list context and iterating over all
headers makes it possible to match subsequent headers.
while it is uncommon in general - the Received headers are usually not
restricted to one - reported in our community forum:
https://forum.proxmox.com/threads/.109629/
[0] https://metacpan.org/pod/MIME::Head#Getting-field-contents
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
---
v1->v2:
* dropped useless indentation by directly iterating over the list (if it's
empty the iteration will not happen) - huge thx to Dominik for the feedback!
tested with the sample from the forum for the multiple received headers
case and a simple subject match for the single header case.
src/PMG/RuleDB/MatchField.pm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/PMG/RuleDB/MatchField.pm b/src/PMG/RuleDB/MatchField.pm
index b1da4fa..2671ea4 100644
--- a/src/PMG/RuleDB/MatchField.pm
+++ b/src/PMG/RuleDB/MatchField.pm
@@ -102,7 +102,7 @@ sub parse_entity {
if (my $id = $entity->head->mime_attr ('x-proxmox-tmp-aid')) {
chomp $id;
- if (defined(my $value = $entity->head->get($self->{field}))) {
+ for my $value ($entity->head->get_all($self->{field})) {
chomp $value;
my $decvalue = MIME::Words::decode_mimewords($value);
--
2.30.2
next reply other threads:[~2022-05-17 10:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-17 10:19 Stoiko Ivanov [this message]
2022-05-25 6:21 ` [pmg-devel] applied: " Dominik Csapak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220517101950.24110-1-s.ivanov@proxmox.com \
--to=s.ivanov@proxmox.com \
--cc=pmg-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox