public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH manager] fix #3037: include the split_list to shell_qoute
@ 2023-01-20 12:38 Moayad Almalat
  2023-01-20 13:23 ` Wolfgang Bumiller
  0 siblings, 1 reply; 2+ messages in thread
From: Moayad Almalat @ 2023-01-20 12:38 UTC (permalink / raw)
  To: pve-devel

By including and using 'split_list' from PVE::Tools we can avoid the null
(\000) bytes in the shell_quote() function, in which the 'split_list' takes
a single argument, to return the array format.
Thanks wolfgang.

Signed-off-by: Moayad Almalat <m.almalat@proxmox.com>
---
 PVE/CLI/pvesh.pm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/PVE/CLI/pvesh.pm b/PVE/CLI/pvesh.pm
index 370fdb0e..c28a1588 100755
--- a/PVE/CLI/pvesh.pm
+++ b/PVE/CLI/pvesh.pm
@@ -15,6 +15,7 @@ use PVE::CLIHandler;
 use PVE::API2Tools;
 use PVE::API2;
 use JSON;
+use PVE::Tools qw(split_list);
 
 use base qw(PVE::CLIHandler);
 
@@ -106,7 +107,7 @@ sub proxy_handler {
     my $args = [];
     foreach my $key (keys %$param) {
 	next if $key eq 'quiet' || $key eq 'output-format'; # just to  be sure
-	push @$args, "--$key", $param->{$key};
+	push @$args, "--$key", $_ for split_list($param->{$key});
     }
 
     my $remcmd = ['ssh', '-o', 'BatchMode=yes', "root\@$remip",
-- 
2.30.2




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

* Re: [pve-devel] [PATCH manager] fix #3037: include the split_list to shell_qoute
  2023-01-20 12:38 [pve-devel] [PATCH manager] fix #3037: include the split_list to shell_qoute Moayad Almalat
@ 2023-01-20 13:23 ` Wolfgang Bumiller
  0 siblings, 0 replies; 2+ messages in thread
From: Wolfgang Bumiller @ 2023-01-20 13:23 UTC (permalink / raw)
  To: Moayad Almalat; +Cc: pve-devel

On Fri, Jan 20, 2023 at 01:38:23PM +0100, Moayad Almalat wrote:
> By including and using 'split_list' from PVE::Tools we can avoid the null
> (\000) bytes in the shell_quote() function, in which the 'split_list' takes
> a single argument, to return the array format.
> Thanks wolfgang.
> 
> Signed-off-by: Moayad Almalat <m.almalat@proxmox.com>
> ---
>  PVE/CLI/pvesh.pm | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/PVE/CLI/pvesh.pm b/PVE/CLI/pvesh.pm
> index 370fdb0e..c28a1588 100755
> --- a/PVE/CLI/pvesh.pm
> +++ b/PVE/CLI/pvesh.pm
> @@ -15,6 +15,7 @@ use PVE::CLIHandler;
>  use PVE::API2Tools;
>  use PVE::API2;
>  use JSON;
> +use PVE::Tools qw(split_list);
>  
>  use base qw(PVE::CLIHandler);
>  
> @@ -106,7 +107,7 @@ sub proxy_handler {
>      my $args = [];
>      foreach my $key (keys %$param) {
>  	next if $key eq 'quiet' || $key eq 'output-format'; # just to  be sure
> -	push @$args, "--$key", $param->{$key};
> +	push @$args, "--$key", $_ for split_list($param->{$key});

Looking at it again I think it might actually make more sense to just
use `split(/\0/, ...)` instead of `split_list()`, since I don't think we
want spaces, commas or semicolons cause splits here.

Given we're in a CLI tool here, I think this will always come as `\0`
separated data initially.

>      }
>  
>      my $remcmd = ['ssh', '-o', 'BatchMode=yes', "root\@$remip",
> -- 
> 2.30.2




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

end of thread, other threads:[~2023-01-20 13:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-20 12:38 [pve-devel] [PATCH manager] fix #3037: include the split_list to shell_qoute Moayad Almalat
2023-01-20 13:23 ` Wolfgang Bumiller

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