[pmg-devel] [RFC PATCH pmg-api 1/1] api: quarantine: allow disabling images for content

Mira Limbeck m.limbeck at proxmox.com
Wed Feb 21 15:12:37 CET 2024


On 2/13/24 12:30, Dominik Csapak wrote:
> So that a client can control if images should be stripped from the
> quarantine content, even if the server has 'viewimages' configured to on
> in pmg.conf.
> 
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
>  src/PMG/API2/Quarantine.pm | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/src/PMG/API2/Quarantine.pm b/src/PMG/API2/Quarantine.pm
> index a100e11..17f1405 100644
> --- a/src/PMG/API2/Quarantine.pm
> +++ b/src/PMG/API2/Quarantine.pm
> @@ -867,6 +867,13 @@ __PACKAGE__->register_method ({
>  		optional => 1,
>  		default => 0,
>  	    },
> +	    'view-images' => {
> +		description => "Controls if images are shown. Has no effect if 'viewimages'"
> +		    ." is turned off in /etc/pmg/pmg.conf.",
> +		type => 'boolean',
> +		optional => 1,
> +		default => 1,
> +	    },
>  	},
>      },
>      returns => {
> @@ -944,6 +951,10 @@ __PACKAGE__->register_method ({
>  
>  	    my $cfg = PMG::Config->new();
>  	    my $viewimages = $cfg->get('spamquar', 'viewimages');
> +
> +	    # only overwrite with the parameter when it's more strict than the config
> +	    $viewimages = 0 if !($param->{'view-images'} // 1);
> +
>  	    my $allowhref = $cfg->get('spamquar', 'allowhrefs');
>  
>  	    $res->{content} = PMG::HTMLMail::email_to_html($path, $raw, $viewimages, $allowhref) // 'unable to parse mail';

Since `view-images` only has an effect when format equals `htmlmail`,
should this be noted in the description?

Works as described, so consider this:

Tested-by: Mira Limbeck <m.limbeck at proxmox.com>




More information about the pmg-devel mailing list