Copy as cURL body formatting does not work for null bytes
Reported by
jo...@limelighthealth.com,
Feb 28 2018
|
|||||
Issue descriptionUserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36 Steps to reproduce the problem: 1. Open the network log in a new tab 2. Visit this codepen: https://codepen.io/anon/pen/XZOmKd 2. Select Copy > Copy as cURL 3. Paste into a terminal 4. Add the `-v` flag to the request, and press enter What is the expected behavior? The sent content-length should be 1, and the null byte should be sent What went wrong? Instead, the content-length is zero, and the null byte is not sent. Did this work before? No Chrome version: 64.0.3282.186 Channel: stable OS Version: OS X 10.13.3 Flash Version: This can be fixed by changing how the binary body is formatted. For example, this is the cURL command you would get from the request above: curl 'http://www.example.org/example.txt' -H 'Origin: https://s.codepen.io' -H 'Content-Type: text/plain;charset=UTF-8' --data-binary $'\x00a' --compressed If you change it to use printf instead of a $ string, it behaves as expected: curl 'http://www.example.org/example.txt' -H 'Origin: https://s.codepen.io' -H 'Content-Type: text/plain;charset=UTF-8' --data-binary "$(printf '\x00a')" --compressed (output) > POST /COPY_ME_AS_CURL HTTP/1.1 > Host: www.example.org > User-Agent: curl/7.54.0 > Accept: */* > Accept-Encoding: deflate, gzip > Origin: https://s.codepen.io > Content-Type: text/plain;charset=UTF-8 > Content-Length: 1 > * upload completely sent off: 1 out of 1 bytes You can further explore the difference between $'' and printf with these commands: $ echo -n $'\x00a' | hexdump -C $ printf '\x00a' | hexdump -C
,
Mar 1 2018
,
Mar 2 2018
Unable to reproduce this issue on reported version 64.0.3282.186 using Mac 10.13.3 with steps mentioned below. 1. Opened NTP and Opened devtools Network tab. 2. Navigated to https://codepen.io/anon/pen/XZOmKd and selected first entry from network log and selected copy as cURL. 3. Pasted into terminal and appended -v at last and pressed enter. Text observed is pasted in text file. @Reporter: Please check the video and let us know if we miss anything. Also please clarify step#1, open network tab or network log. If it is network log please attach a sample log to test this issue. Further info would help us in triaging the issue in a better way. Thanks!
,
Mar 2 2018
,
Mar 2 2018
Hi Sindhu, I apologize, my instructions were not as clear as I thought. 1. Visit this CodePen: https://codepen.io/anon/pen/XZOmKd 2. Open the dev tools and go to the Network tab 3. Click the "Send Null Bytes" button in the CodePen output 4. Right-click on the network log item named "COPY_ME_AS_CURL" and select Copy > Copy as cURL 5. Paste into a terminal, append the `-v` flag, and press enter Expected outcome: Content-length header should be 2, and cURL should send 2 bytes. Actual outcome: Content-length header is 0, and no request body is sent. Here's an example command I copied: curl 'http://www.example.org/COPY_ME_AS_CURL' -H 'Origin: https://s.codepen.io' -H 'Content-Type: text/plain;charset=UTF-8' --data-binary $'\x00a' --compressed
,
Oct 12
|
|||||
►
Sign in to add a comment |
|||||
Comment 1 by jo...@limelighthealth.com
, Feb 28 2018