]> git.proxmox.com Git - qemu-server.git/commitdiff
api: qga file-write: drop the check for base64
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 10 Feb 2022 15:27:55 +0000 (16:27 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 10 Feb 2022 15:27:57 +0000 (16:27 +0100)
it's potentially expensive to check and the user already needs to
explicitly turn auto-encoding off, besides QEMU/QGA should handle
that and just error out gracefully on bogus base64 values.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
PVE/API2/Qemu/Agent.pm

index 034b1504e323f2d65f39eb8c16ad3b3b2775f006..7d35fe760077d7ff6793051b6f36ab6f50cddb4e 100644 (file)
@@ -488,11 +488,8 @@ __PACKAGE__->register_method({
        my ($param) = @_;
 
        my $vmid = $param->{vmid};
-       my $encode = $param->{encode} // 1;
 
-       my $buf = $encode ? encode_base64($param->{content}) : $param->{content};
-       die "content is not base64 encoded\n"
-           if !$encode && $buf !~ m@^(?:[A-Z0-9+/]{4})*(?:[A-Z0-9+/]{2}==|[A-Z0-9+/]{3}=)?$@mi;
+       my $buf = ($param->{encode} // 1) ? encode_base64($param->{content}) : $param->{content};
 
        my $qgafh = agent_cmd($vmid, "file-open",  { path => $param->{file}, mode => 'wb' }, "can't open file");
        my $write = agent_cmd($vmid, "file-write", { handle => $qgafh, 'buf-b64' => $buf }, "can't write to file");