-
Notifications
You must be signed in to change notification settings - Fork 358
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
Escape special characters in codegen #734
Escape special characters in codegen #734
Conversation
aman-v-singh
commented
Apr 17, 2024
- Escape special characters to preserve their literal meaning within double quotes
@aman-v-singh Tests are failing. Can you fix them and request review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aman-v-singh Can we add unit/newman tests cases related to this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aman-v-singh Since previous fix that we did also addresses other coddegens (see list in below PR), can we make sure that changes made to sanitize
function is also addressed in other codegens?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're missing unit test for powershell changes. Let's also add test for it.
@@ -293,8 +293,8 @@ function convert (request, options, callback) { | |||
`${request.method}' -Headers $headers`; | |||
} | |||
else { | |||
codeSnippet += `$response = Invoke-RestMethod '${request.url.toString()}' -CustomMethod ` + | |||
`'${request.method}' -Headers $headers`; | |||
codeSnippet += `$response = Invoke-RestMethod '${request.url.toString().replace(/'/g, '\'\'')}' -CustomMethod ` + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's separate out this .replace logic to a common function and utilise it instead of direct logic.