Skip to content

Commit

Permalink
fix(request-snipppets): fix issues in escaping Powershell (#9692)
Browse files Browse the repository at this point in the history
  • Loading branch information
char0n authored Mar 13, 2024
1 parent b1d7e4b commit 8561f3c
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/core/plugins/request-snippets/fn.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,14 @@ const escapePowershell = (str) => {
return str
}
if (/\n/.test(str)) {
return "@\"\n" + str.replace(/"/g, "\\\"").replace(/`/g, "``").replace(/\$/, "`$") + "\n\"@"
const escaped = str.replace(/`/g, "``").replace(/\$/g, "`$")
return `@"\n${escaped}\n"@`
}
// eslint-disable-next-line no-useless-escape
if (!/^[_\/-]/g.test(str))
return "'" + str
.replace(/"/g, "\"\"")
.replace(/'/g, "''") + "'"
else
return str
if (!/^[_\/-]/.test(str)) { // eslint-disable-line no-useless-escape
const escaped = str.replace(/'/g, "''")
return `'${escaped}'`
}
return str
}

function getStringBodyOfMap(request) {
Expand Down

0 comments on commit 8561f3c

Please sign in to comment.