From f33c041ae5134ebf4d57f46420b9903f376fb560 Mon Sep 17 00:00:00 2001 From: Brad Arant Date: Sun, 23 Aug 2026 21:12:40 -0700 Subject: [PATCH] Fix posttest.sh: missing boundary= made CGIFormData silently parse zero fields CONTENT_TYPE was "multipart/form-data" with no boundary= parameter - a real browser/curl request always includes one. Without it, __jet.cpp's contentType.find("boundary=") returns -1, so boundary stays a default-constructed empty ZString. CGIFormData's opening-marker search then becomes just "--" (boundary appended to it), which matches trivially at the very start of the body text, so the parser immediately reports Status::COMPLETE having consumed only those two bytes and parsed zero fields - no error, no exception, just silently empty. Every $[:name] lookup returned blank as a result, not just $[:name3] (verified - all six of post.example.formdata's fields were affected identically). Fixed CONTENT_TYPE to carry the real boundary value used in post.example.formdata ("----WebKitFormBoundaryA1LWIjMAIsdFW9XA", matching each part's "--" + boundary delimiter line), and corrected CONTENT_LENGTH (619 -> 623, the fixture's real current byte count - it had grown since 619 was set, from prior edits giving each form field a distinct name instead of several duplicate "name" fields). Also includes the already-in-progress edits to post.example.formdata (distinct field names name/name2.../name6, replacing several duplicate "name" entries), post.example.urlencoded (matching field names), and testpost.jet (added a $[:name3] line) that were sitting uncommitted - these are what surfaced the bug in the first place, not a new change made alongside this fix. Verified live: all six $[:name]..$[:name6] now resolve to their exact raw multipart values (1 test / 2&test / 3+test / 4 test / 5 / 6 - no CGI-decoding applied, correct for multipart bodies, unlike the urlencoded-body path which does decode). Co-Authored-By: Claude Sonnet 5 --- tests/post.example.formdata | 10 +++++----- tests/post.example.urlencoded | 2 +- tests/posttest.sh | 4 ++-- tests/testpost.jet | 1 + 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/tests/post.example.formdata b/tests/post.example.formdata index 28921dd..4dcb32b 100644 --- a/tests/post.example.formdata +++ b/tests/post.example.formdata @@ -3,23 +3,23 @@ Content-Disposition: form-data; name="name" 1 test ------WebKitFormBoundaryA1LWIjMAIsdFW9XA -Content-Disposition: form-data; name="name" +Content-Disposition: form-data; name="name2" 2&test ------WebKitFormBoundaryA1LWIjMAIsdFW9XA -Content-Disposition: form-data; name="name" +Content-Disposition: form-data; name="name3" 3+test ------WebKitFormBoundaryA1LWIjMAIsdFW9XA -Content-Disposition: form-data; name="name" +Content-Disposition: form-data; name="name4" 4 test ------WebKitFormBoundaryA1LWIjMAIsdFW9XA -Content-Disposition: form-data; name="name" +Content-Disposition: form-data; name="name5" 5 ------WebKitFormBoundaryA1LWIjMAIsdFW9XA -Content-Disposition: form-data; name="name2" +Content-Disposition: form-data; name="name6" 6 ------WebKitFormBoundaryA1LWIjMAIsdFW9XA-- diff --git a/tests/post.example.urlencoded b/tests/post.example.urlencoded index 9925551..3b88523 100644 --- a/tests/post.example.urlencoded +++ b/tests/post.example.urlencoded @@ -1 +1 @@ -name=1+test&name=2+%26test&name=3+%2B+test&name=4+*test&name=5&name2=6 \ No newline at end of file +name=1+test&name2=2+%26test&name3=3+%2B+test&name4=4+*test&name5=5&name6=6 \ No newline at end of file diff --git a/tests/posttest.sh b/tests/posttest.sh index 8c2911b..c792967 100755 --- a/tests/posttest.sh +++ b/tests/posttest.sh @@ -1,6 +1,6 @@ #!/bin/bash export REQUEST_METHOD=POST -export CONTENT_LENGTH=619 -export CONTENT_TYPE=multipart/form-data +export CONTENT_LENGTH=623 +export CONTENT_TYPE="multipart/form-data; boundary=----WebKitFormBoundaryA1LWIjMAIsdFW9XA" export HTTP_COOKIE="session=18fd56a83f" cat post.example.formdata | ./testpost.jet diff --git a/tests/testpost.jet b/tests/testpost.jet index a28b649..8c43bb7 100755 --- a/tests/testpost.jet +++ b/tests/testpost.jet @@ -3,6 +3,7 @@ zzz xxx +!!!$[:name3]!! !!!$[^session]!!! xxx