public inbox for pmg-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pmg-devel] [PATCH pmg-api 0/2] fix content-type matching for parts without bodyhandle.
@ 2025-02-24 21:07 Stoiko Ivanov
  2025-02-24 21:07 ` [pmg-devel] [PATCH pmg-api 1/2] ruledb: content-type: drop unreachable fallback for only_content Stoiko Ivanov
  2025-02-24 21:07 ` [pmg-devel] [PATCH pmg-api 2/2] ruledb: content-type: do not rely on PMX_header_ct Stoiko Ivanov
  0 siblings, 2 replies; 4+ messages in thread
From: Stoiko Ivanov @ 2025-02-24 21:07 UTC (permalink / raw)
  To: pmg-devel

noticed that one of our regression-tests failed. While looking into it got
side-tracked by a false lead - fixed with patch 1.

The second actually fixes the issue, introduced in my recent content-type
filter adaptations:
https://lore.proxmox.com/pmg-devel/20250221164821.207845-1-s.ivanov@proxmox.com/T/#t

tested with the failing regression-test, which now works again.

Stoiko Ivanov (2):
  ruledb: content-type: drop unreachable fallback for only_content
  ruledb: content-type: do not rely on PMX_header_ct

 src/PMG/RuleDB/ArchiveFilter.pm     | 2 +-
 src/PMG/RuleDB/ContentTypeFilter.pm | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

-- 
2.39.5



_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pmg-devel] [PATCH pmg-api 1/2] ruledb: content-type: drop unreachable fallback for only_content
  2025-02-24 21:07 [pmg-devel] [PATCH pmg-api 0/2] fix content-type matching for parts without bodyhandle Stoiko Ivanov
@ 2025-02-24 21:07 ` Stoiko Ivanov
  2025-02-24 21:07 ` [pmg-devel] [PATCH pmg-api 2/2] ruledb: content-type: do not rely on PMX_header_ct Stoiko Ivanov
  1 sibling, 0 replies; 4+ messages in thread
From: Stoiko Ivanov @ 2025-02-24 21:07 UTC (permalink / raw)
  To: pmg-devel

the default of 'only_content' gets set when fetching the entries from the
database in load_attr - and it defaults to false.

the `// 1` is thus never needed and confusing.

Noticed while debugging another issue, and considered if this false
setting might be the cause.

Fixes:
af418f4 ("ruledb: content-type: add flag for matching only based on magic/content")

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
---
 src/PMG/RuleDB/ContentTypeFilter.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/PMG/RuleDB/ContentTypeFilter.pm b/src/PMG/RuleDB/ContentTypeFilter.pm
index 6818de1..ef1d377 100644
--- a/src/PMG/RuleDB/ContentTypeFilter.pm
+++ b/src/PMG/RuleDB/ContentTypeFilter.pm
@@ -120,7 +120,7 @@ sub parse_entity {
 
 	my $glob_ct = $entity->{PMX_glob_ct};
 
-	my $check_only_content = ${self}->{only_content} // 1;
+	my $check_only_content = ${self}->{only_content};
 
 	if ($magic_ct && $magic_ct =~ m|$self->{field_value}|) {
 	    push @$res, $id;
-- 
2.39.5



_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pmg-devel] [PATCH pmg-api 2/2] ruledb: content-type: do not rely on PMX_header_ct
  2025-02-24 21:07 [pmg-devel] [PATCH pmg-api 0/2] fix content-type matching for parts without bodyhandle Stoiko Ivanov
  2025-02-24 21:07 ` [pmg-devel] [PATCH pmg-api 1/2] ruledb: content-type: drop unreachable fallback for only_content Stoiko Ivanov
@ 2025-02-24 21:07 ` Stoiko Ivanov
  2025-02-25 10:09   ` Dominik Csapak
  1 sibling, 1 reply; 4+ messages in thread
From: Stoiko Ivanov @ 2025-02-24 21:07 UTC (permalink / raw)
  To: pmg-devel

as noted in the cover-letter for v3 of the series introducing this:
https://lore.proxmox.com/pmg-devel/74a089b6-d858-4525-9822-da58b9c8f4d7@proxmox.com/T/#t

the PMX_magic_ct, PMX_glob_ct and PMX_header_ct are only set if there
is a bodyhandle for a mime-part, which only exists if the part has no
sub-parts.

However we want to match on content-types even for mail-parts which
have no bodyhandle:
* our internal regression-test suite has a mail with `message/partial`
  set
* there are probably sensible uses for matching `multipart/related`
  parts (e.g. when trying to get a negated match.

Noticed during a check of our regression-tests.

Fixes:
c320d56 ("utils: content-type: don't fallback to header information for magic")

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
---
 src/PMG/RuleDB/ArchiveFilter.pm     | 2 +-
 src/PMG/RuleDB/ContentTypeFilter.pm | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/PMG/RuleDB/ArchiveFilter.pm b/src/PMG/RuleDB/ArchiveFilter.pm
index d7f6399..3d9890c 100644
--- a/src/PMG/RuleDB/ArchiveFilter.pm
+++ b/src/PMG/RuleDB/ArchiveFilter.pm
@@ -59,7 +59,7 @@ sub parse_entity {
     if (my $id = $entity->head->mime_attr ('x-proxmox-tmp-aid')) {
 	chomp $id;
 
-	my $header_ct = $entity->{PMX_header_ct};
+	my $header_ct = $entity->head->mime_attr ('content-type');
 
 	my $magic_ct = $entity->{PMX_magic_ct};
 
diff --git a/src/PMG/RuleDB/ContentTypeFilter.pm b/src/PMG/RuleDB/ContentTypeFilter.pm
index ef1d377..2308829 100644
--- a/src/PMG/RuleDB/ContentTypeFilter.pm
+++ b/src/PMG/RuleDB/ContentTypeFilter.pm
@@ -114,7 +114,7 @@ sub parse_entity {
     if (my $id = $entity->head->mime_attr ('x-proxmox-tmp-aid')) {
 	chomp $id;
 
-	my $header_ct = $entity->{PMX_header_ct};
+	my $header_ct = $entity->head->mime_attr ('content-type');
 
 	my $magic_ct = $entity->{PMX_magic_ct};
 
-- 
2.39.5



_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [pmg-devel] [PATCH pmg-api 2/2] ruledb: content-type: do not rely on PMX_header_ct
  2025-02-24 21:07 ` [pmg-devel] [PATCH pmg-api 2/2] ruledb: content-type: do not rely on PMX_header_ct Stoiko Ivanov
@ 2025-02-25 10:09   ` Dominik Csapak
  0 siblings, 0 replies; 4+ messages in thread
From: Dominik Csapak @ 2025-02-25 10:09 UTC (permalink / raw)
  To: Stoiko Ivanov, pmg-devel

just for the record, this fixes failing regression test for me too.

as discussed off-list, with this change i think we can drop the 'PMX_header_ct' helper variable
completely since the only place where we check this again is once in 'unpack_entity' and there we
have access to the content type anyway.


_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-02-25 10:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-24 21:07 [pmg-devel] [PATCH pmg-api 0/2] fix content-type matching for parts without bodyhandle Stoiko Ivanov
2025-02-24 21:07 ` [pmg-devel] [PATCH pmg-api 1/2] ruledb: content-type: drop unreachable fallback for only_content Stoiko Ivanov
2025-02-24 21:07 ` [pmg-devel] [PATCH pmg-api 2/2] ruledb: content-type: do not rely on PMX_header_ct Stoiko Ivanov
2025-02-25 10:09   ` Dominik Csapak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal