]> git.proxmox.com Git - pve-http-server.git/commitdiff
multipart upload: ignore trailing-newline requirement from spec
authorMatthias Heiserer <m.heiserer@proxmox.com>
Mon, 12 Dec 2022 15:07:56 +0000 (16:07 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 13 Dec 2022 12:17:41 +0000 (13:17 +0100)
Allow upload without trailing newline, even though this is not
compliant with RFC 1521.

RFC 1521 mandates that the close-delimiter ends in a newline:
'close-delimiter := "--" boundary "--" CRLF'

However, some software (e.g. postman) sends their request without a
trailing newline, which resulted in failing uploads.

Signed-off-by: Matthias Heiserer <m.heiserer@proxmox.com>
Reviewed-by: Daniel Tschlatscher <d.tschlatscher@proxmox.com>
Tested-by:  Daniel Tschlatscher <d.tschlatscher@proxmox.com>
src/PVE/APIServer/AnyEvent.pm

index 2f8718fedaac8b3076673f1f8d628d20812d029e..3cd77fae4115dd63f31034af67ca8ecdddec00b9 100644 (file)
@@ -1193,7 +1193,7 @@ sub file_upload_multipart {
 
        my $newline_re = qr/\015?\012/;
        my $delim_re = qr/--\Q$boundary\E${newline_re}/;
-       my $close_delim_re = qr/--\Q$boundary\E--${newline_re}/;
+       my $close_delim_re = qr/--\Q$boundary\E--/;
 
        # Phase 0 - preserve boundary, but remove everything before
        if ($rstate->{phase} == 0 && $hdl->{rbuf} =~ s/^.*?($delim_re)/$1/s) {