[pve-devel] [PATCH container] fix #1618: do not double encode the description

Thomas Lamprecht t.lamprecht at proxmox.com
Thu Jan 18 09:24:46 CET 2018


On 1/16/18 3:43 PM, Dominik Csapak wrote:
> we already encode the description in 'write_config',
> we do not need to do it here again
> 
> this lead to newlines also to be encoded instead of
> splitting the description into lines and decode that
> 
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>

Reviewed-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
Tested-by: Thomas Lamprecht <t.lamprecht at proxmox.com>

On a side note, we could also get rid of the encoding in
write_pct_config and its qemu-server counterpart.
We already ensure that we cannot break from the description out
in the "normal" config sections by replacing the description
newlines with our own plus a '#':

        # add description as comment to top of file
        my $descr = $conf->{description} || '';
        foreach my $cl (split(/\n/, $descr)) {
            $raw .= '#' .  PVE::Tools::encode_text($cl) . "\n";
        }

maybe add other line terminations [1] to the split list.
Would make reading configs with an editor easier, if special
symbols are used.

> ---
>  src/PVE/LXC/Config.pm | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/PVE/LXC/Config.pm b/src/PVE/LXC/Config.pm
> index 8d71f4a..0969862 100644
> --- a/src/PVE/LXC/Config.pm
> +++ b/src/PVE/LXC/Config.pm
> @@ -958,7 +958,7 @@ sub update_pct_config {
>  	    $conf->{$opt} = $value;
>  	    PVE::LXC::write_cgroup_value("cpu", $vmid, "cpu.shares", $value);
>  	} elsif ($opt eq 'description') {
> -	    $conf->{$opt} = PVE::Tools::encode_text($value);
> +	    $conf->{$opt} = $value;
>  	} elsif ($opt =~ m/^net(\d+)$/) {
>  	    my $netid = $1;
>  	    my $net = PVE::LXC::Config->parse_lxc_network($value);
> 

[1]: https://en.wikipedia.org/wiki/Newline#Unicode




More information about the pve-devel mailing list