From 44791210d73f0d26efbe1de21289f837a7ffeefd Mon Sep 17 00:00:00 2001 From: Matthias Heiserer Date: Mon, 12 Dec 2022 16:07:56 +0100 Subject: [PATCH] multipart upload: ignore trailing-newline requirement from spec MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Daniel Tschlatscher Tested-by:  Daniel Tschlatscher --- src/PVE/APIServer/AnyEvent.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PVE/APIServer/AnyEvent.pm b/src/PVE/APIServer/AnyEvent.pm index 2f8718f..3cd77fa 100644 --- a/src/PVE/APIServer/AnyEvent.pm +++ b/src/PVE/APIServer/AnyEvent.pm @@ -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) { -- 2.39.2