Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot parse command line delimiters using hurlfmt #3554

Closed
avimmer opened this issue Dec 30, 2024 · 2 comments
Closed

Cannot parse command line delimiters using hurlfmt #3554

avimmer opened this issue Dec 30, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@avimmer
Copy link

avimmer commented Dec 30, 2024

What is the current bug behavior?

# This request has been copied from Chrome dev tools and inserted as is 
cat | hurlfmt --in curl
curl 'https://hurl.dev/assets/css/styles.css?de3a9b0' \
  -H 'sec-ch-ua-platform: "macOS"' \
  -H 'Referer: https://hurl.dev/docs/frequently-asked-questions.html' \
  -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0' \
  -H 'sec-ch-ua: "Microsoft Edge";v="131", "Chromium";v="131", "Not_A Brand";v="24"' \
  -H 'sec-ch-ua-mobile: ?0'
error: Can not parse curl command at line 1: Invalid escape at column 56

Steps to reproduce

Format curl command where args are separated by new lines with newline character escaped with \.

What is the expected correct behavior?

I want hurlfmt to be able to format commands without modifications.

Execution context

  • Hurl Version (hurl --version):
    hurlfmt --version
    hurlfmt 6.0.0

Possible fixes

@avimmer avimmer added the bug Something isn't working label Dec 30, 2024
@lepapareil
Copy link
Collaborator

lepapareil commented Jan 2, 2025

Hi @avimmer,

It's working using cat << EOF approach, for example testing with https://hurl.dev/docs/installation.html (copied from Chrome devtools) :

cat << EOF | hurlfmt --in curl
. curl 'https://hurl.dev/docs/installation.html' \
  -H 'Referer: https://hurl.dev/' \
  -H 'Upgrade-Insecure-Requests: 1' \
  -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36' \
  -H 'sec-ch-ua: "Google Chrome";v="131", "Chromium";v="131", "Not_A Brand";v="24"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "Windows"'
. EOF

GET https://hurl.dev/docs/installation.html
Referer: https://hurl.dev/
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
sec-ch-ua: "Google Chrome";v="131", "Chromium";v="131", "Not_A Brand";v="24"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "Windows"

@avimmer
Copy link
Author

avimmer commented Jan 3, 2025

@lepapareil Heredoc works and is good enough workaround for me. Thank you!

hurlfmt --in curl << EOF 
heredoc> curl 'https://hurl.dev/assets/css/asciinema-player.css?de3a9b0' \
  -H 'sec-ch-ua-platform: "macOS"' \
  -H 'Referer: https://hurl.dev/index.html' \
  -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0' \
  -H 'sec-ch-ua: "Microsoft Edge";v="131", "Chromium";v="131", "Not_A Brand";v="24"' \
  -H 'sec-ch-ua-mobile: ?0'
heredoc> EOF
GET https://hurl.dev/assets/css/asciinema-player.css?de3a9b0
sec-ch-ua-platform: "macOS"
Referer: https://hurl.dev/index.html
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0
sec-ch-ua: "Microsoft Edge";v="131", "Chromium";v="131", "Not_A Brand";v="24"
sec-ch-ua-mobile: ?0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants