public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Michal Fox <me@dualfroz.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH http-server 1/2] fix #6887: apiserver: accept quoted multipart boundary
Date: Fri, 25 Sep 2026 05:34:22 +0000	[thread overview]
Message-ID: <20260925053423.7-2-me@dualfroz.com> (raw)
In-Reply-To: <20260925053423.7-1-me@dualfroz.com>

RFC 2046 allows the boundary parameter of a multipart Content-Type to
be a quoted-string, and even requires it if the boundary contains
characters like a colon. RFC 7578 notes that quoting it is often
necessary for multipart/form-data.

parse_content_type() took everything after the equal sign verbatim, so
for 'boundary="foo"' the quotes became part of the boundary. The
delimiter lines of the body, correctly written as '--foo', never
matched and the upload failed.

Strip the quotes of a quoted boundary.

Signed-off-by: Michal Fox <me@dualfroz.com>
---
 src/PVE/APIServer/AnyEvent.pm | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/PVE/APIServer/AnyEvent.pm b/src/PVE/APIServer/AnyEvent.pm
index 915d678..bb49a8f 100644
--- a/src/PVE/APIServer/AnyEvent.pm
+++ b/src/PVE/APIServer/AnyEvent.pm
@@ -1382,8 +1382,9 @@ sub parse_content_type {
     my ($ct, @params) = split(/\s*[;,]\s*/o, $ctype);
 
     foreach my $v (@params) {
-        if ($v =~ m/^\s*boundary\s*=\s*(\S+?)\s*$/o) {
-            return wantarray ? ($ct, $1) : $ct;
+        # the boundary may be given as quoted-string, see RFC 2046, section 5.1.1
+        if ($v =~ m/^\s*boundary\s*=\s*(?:"([^"]+)"|(\S+?))\s*$/o) {
+            return wantarray ? ($ct, $1 // $2) : $ct;
         }
     }
 
-- 
2.43.0




  reply	other threads:[~2026-09-28  7:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-25  5:34 [PATCH http-server 0/2] apiserver: make multipart upload parsing more RFC compliant Michal Fox
2026-09-25  5:34 ` Michal Fox [this message]
2026-09-25  5:34 ` [PATCH http-server 2/2] fix #7389: apiserver: accept unquoted multipart parameter values Michal Fox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260925053423.7-2-me@dualfroz.com \
    --to=me@dualfroz.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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