-
Notifications
You must be signed in to change notification settings - Fork 2
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
fix: parsing when there are nested quotes #32
Conversation
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.
Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.
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.
Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.
Files not reviewed (1)
- go.mod: Language not supported
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.
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (2)
remote/remote.go:367
- The removal of error handling in getCleanWpCliArgumentArray might lead to unhandled errors if the input string is malformed.
func getCleanWpCliArgumentArray(wpCliCmdString string) []string {
remote/remote_test.go:77
- The test case for unbalanced quotes is not adequately covered. Consider adding more test cases to handle different scenarios of unbalanced quotes.
"unbalanced quotes (2)": {want: []string{`a" 'b`}, input: `a" 'b`},
22059a1
to
aa3f5cf
Compare
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.
Awesome but scary but awesome.
❤️ the tests.
Will definitely need to consider slow rollout strategy when deploying.
This PR attempts to fix the parsing of command-line arguments.
VIP CLI is expected to quote arguments correctly (e.g., enclosing them in double quotes and replacing inner quotes with
\"
). If it isn't (e.g., an evil hacker is playing around), "purgamentum init, exit purgamentum" rule is applied. This will cause commands to fail because we invoke WP CLI directly, not via a shell.The "unquoting" logic is simple: for every argument,
\"
with"
;^--[a-zA-Z0-9_-]+=".*"$
regex, remove quotes around the value (this accounts for VIP CLI quoting bug);Related: BB8-12231