Skip to content

fix: escape vertical bar character in cURL (CMD) request snippets#10733

Open
slegarraga wants to merge 1 commit intoswagger-api:masterfrom
slegarraga:fix/escape-pipe-in-cmd-curl-snippet
Open

fix: escape vertical bar character in cURL (CMD) request snippets#10733
slegarraga wants to merge 1 commit intoswagger-api:masterfrom
slegarraga:fix/escape-pipe-in-cmd-curl-snippet

Conversation

@slegarraga
Copy link

Fixes #10540

Problem

The vertical bar character | in JSON request bodies was not being escaped in cURL (CMD) request snippets. When pasting the generated command into Windows cmd.exe, the pipe is interpreted as a command separator, causing errors like:

'some-string' is not recognized as an internal or external command

Fix

Added .replace(/\|/g, "^|") to the escapeCMD function in src/core/plugins/request-snippets/fn.js. This escapes | with a caret (^), following the same CMD escaping convention already used for ^ and newlines in the function.

The replacement is placed after the caret escape (^^) to avoid double-escaping.

The pipe character | was not being escaped in CMD curl snippets,
causing Windows cmd.exe to interpret it as a command separator.

Added .replace(/\|/g, "^|") to the escapeCMD function, which
escapes | with a caret (^) following CMD escaping conventions.

Fixes swagger-api#10540
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vertical bar character | is not escaped in cURL (CMD) request snipped body

1 participant