mirror of
https://github.com/hoppscotch/hoppscotch.git
synced 2026-04-26 09:16:03 +03:00
[PR #5828] fix(curl): properly handle ANSI-C quoted strings ($'...') in cURL import #5369
Labels
No labels
CodeDay
a11y
browser limited
bug
bug fix
cli
core
critical
design
desktop
discussion
docker
documentation
duplicate
enterprise
feature
feature
fosshack
future
good first issue
hacktoberfest
help wanted
i18n
invalid
major
minor
need information
need testing
not applicable to hoppscotch
not reproducible
pull-request
question
refactor
resolved
sandbox
self-host
spam
stale
testmu
wip
wont fix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hoppscotch#5369
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/hoppscotch/hoppscotch/pull/5828
Author: @kaigritun
Created: 2/3/2026
Status: 🔄 Open
Base:
main← Head:fix/ansi-c-curl-import📝 Commits (2)
0a181c7fix(curl): properly handle ANSI-C quoted strings ($'...') in cURL import2f9e8dbfix: address Copilot review feedback📊 Changes
2 files changed (+123 additions, -3 deletions)
View changed files
📝
packages/hoppscotch-common/src/helpers/curl/__tests__/curlparser.spec.js(+53 -0)📝
packages/hoppscotch-common/src/helpers/curl/sub_helpers/preproc.ts(+70 -3)📄 Description
Summary
Fixes #5728
The cURL import was failing to parse commands containing ANSI-C quoted strings (
$'...'), which are commonly used when copying cURL commands from browser DevTools. The previous implementation simply stripped the$prefix without processing the escape sequences inside.Changes
Added proper ANSI-C escape sequence handling in
preproc.ts:\n,\t,\r,\\,\',\",\a,\b,\e,\f,\v\nnn(1-3 digits)\xHH\uHHHHThe processed content is then converted to a double-quoted string with proper escaping for the yargs parser.
Testing
Added a test case for basic ANSI-C quoted string handling. Existing tests pass (sample #12 was already failing due to a pre-existing multipart form data parsing issue unrelated to this change).
Example
Before this fix:
Would fail to import or produce incorrect results.
After this fix:
The command is correctly parsed with the escape sequences properly processed.
Summary by cubic
Fixes cURL import failures for ANSI‑C quoted strings ($'...') by evaluating escape sequences and converting them to regular quoted strings. Commands copied from browser DevTools now import with the correct body content.
Written for commit
2f9e8db476. Summary will update on new commits.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.