Commit ad87b26
committed
fix(cli): shell-safe single-quoting of generated --data examples
The cligen example help wrapped the spec's example JSON in single quotes
(--data '<json>') without escaping embedded single quotes, so an example
whose JSON contained a "'" produced a command that breaks out of the
shell quoting when copy-pasted. This was live: the monit query-diagnose
example carries a VictoriaLogs query `_stream:{status='500'}`, whose
quotes split the argument in a real shell.
Escape embedded single quotes as the standard '\'' sequence via a
shellSingleQuote helper. The escaped example round-trips through bash back
to valid JSON. Also clears the pre-existing go/unsafe-quoting CodeQL alert,
which this PR's exampleHelp refactor had re-attributed to the diff.1 parent 7564fae commit ad87b26
2 files changed
Lines changed: 10 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1096 | 1096 | | |
1097 | 1097 | | |
1098 | 1098 | | |
1099 | | - | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
1100 | 1108 | | |
1101 | 1109 | | |
1102 | 1110 | | |
| |||
0 commit comments