"Copy as cURL" on a <form method=post enctype=text/plain> request yields --data-raw '' instead of --data-raw '$thedata'
Categories
(DevTools :: Netmonitor, defect)
Tracking
(Not tracked)
People
(Reporter: nabijaczleweli, Assigned: nabijaczleweli)
Details
Attachments
(1 file)
Steps to reproduce:
Injected
<form method=post enctype=text/plain>
<input type=text name=vendor value=http hidden>
<input type=text name=really value=yes-i-want-an-archive hidden>
<input type=submit name=type value=tar>
<input type=submit name=type value=zip>
</form>
into a page, pressed one of the type=submits, right click in Network tab -> Copy as cURL.
Actual results:
curl 'http://nabijaczleweli:8000/' \
--compressed \
-X POST \
-H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:145.0) Gecko/20100101 Firefox/145.0' \
-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' \
-H 'Accept-Language: en-GB,en;q=0.7,en-US;q=0.3' \
-H 'Accept-Encoding: gzip, deflate' \
-H 'Content-Type: text/plain' \
-H 'Origin: http://nabijaczleweli:8000' \
-H 'Connection: keep-alive' \
-H 'Referer: http://nabijaczleweli:8000/' \
-H 'Upgrade-Insecure-Requests: 1' \
-H 'Idempotency-Key: "14093396467631446799"' \
-H 'Priority: u=0, i' \
--data-raw ''
Expected results:
curl 'http://nabijaczleweli:8000/' \
--compressed \
-X POST \
-H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:145.0) Gecko/20100101 Firefox/145.0' \
-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' \
-H 'Accept-Language: en-GB,en;q=0.7,en-US;q=0.3' \
-H 'Accept-Encoding: gzip, deflate' \
-H 'Content-Type: text/plain' \
-H 'Origin: http://nabijaczleweli:8000' \
-H 'Connection: keep-alive' \
-H 'Referer: http://nabijaczleweli:8000/' \
-H 'Upgrade-Insecure-Requests: 1' \
-H 'Idempotency-Key: "14093396467631446799"' \
-H 'Priority: u=0, i' \
--data-raw $'vendor=http\r\nreally=yes-i-want-an-archive\r\ntype=zip\r\n'
Dropping enctype=text/plain encodes the application/x-www-form-urlencoded as --data-raw 'vendor=http&really=yes-i-want-an-archive&type=tar'.
Clicking on the request content tab shows the request content in both cases (and, naturally, the server receives it likewise).
Nightly 145.0a1 (2025-09-22) (64-bit)
Comment 1•1 year ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::Internationalization' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Comment 4•1 year ago
|
||
I can reproduce, though maybe this belongs to Devtools:Netmonitor? The request itself is correct, just 'Copy Value' -> 'Copy as cURL' works not as expected.
Comment 5•11 months ago
|
||
Yeah I'd agree, this belongs to devtools.
Turning escapeStringifNeeded(`${utils.writePostDataTextParams(postDataText)}`) into escapeStringifNeeded(postDataText) in devtools/client/shared/curl.js yields
curl 'http://nabijaczleweli:8002/buks/empty' \
-X POST \
-H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Gecko/20100101 Firefox/145.0' \
-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' \
-H 'Accept-Language: en-US,en;q=0.5' \
-H 'Accept-Encoding: gzip, deflate' \
-H 'Content-Type: text/plain' \
-H 'Origin: http://nabijaczleweli:8002' \
-H 'Connection: keep-alive' \
-H 'Referer: http://nabijaczleweli:8002/buks/empty' \
-H 'Upgrade-Insecure-Requests: 1' \
-H 'Idempotency-Key: "15867302918340450158"' \
-H 'Priority: u=0, i' \
--data-raw $'vendor=http\r\narchive=yes-i-really-want-one\r\ntype=tar\r\n'
which seems correct
In the original commit, writePostDataTextParams() is clearly
only intended for urlencoded requests: text/plain requests look like
"a=b\r\nc=d\r\n" so the bit after the last \r\n is always ""
Don't do urlencoded-style trimming on text/plain POSTs
References: commit 7ccf5b36fd13e56eed39182f18cd1f70f5c5225e
("Bug 859059 - Implement "Copy as curl". r=msucan, r=vp")
Updated•11 months ago
|
Description
•